シェル ウィンドウに一連のタブがあり、コンテンツ コントロールである 1 つのメイン領域があります。また、特定のタブが選択されたときにオンデマンドでロードしたいモジュールが 4 つあります。したがって、tab1 が選択されている場合は moduleA をロードし、tab2 が選択されている場合は ModuleB をロードします。アプリケーションの起動時に最初のモジュールがロードされます。問題は、タブを変更しても何も起こらないことです。厳しいエラーはありません。私は、このバージョンの WPF および Silverlight 用のプリズム コンポジット アプリケーション ガイダンス - 2009 年 10 月を使用しています。
私はこのアプローチを試しました:
シェル:
public partial class Shell : RibbonWindow, IShellView
{
private readonly IRegionManager regionManager;
private readonly IModuleManager moduleManager;
public Shell(IModuleManager moduleManager)
{
this.moduleManager = moduleManager;
InitializeComponent();
}
public void ShowView()
{
this.Show();
}
private void onTabSelection(object sender, RoutedEventArgs e)
{
this.moduleManager.LoadModule("ModuleB");
}
}
ブートストラップ:
public partial class MyBootstrapper : UnityBootstrapper
{
protected override IModuleCatalog GetModuleCatalog()
{
var catalog = new ModuleCatalog();
catalog.AddModule(typeof(ModuleA)).AddModule(typeof(ModuleB));
return catalog;
}
protected override void ConfigureContainer()
{
Container.RegisterType<IShellView, Shell>();
base.ConfigureContainer();
}
protected override DependencyObject CreateShell()
{
ShellPresenter presenter = Container.Resolve<ShellPresenter>();
IShellView view = presenter.View;
view.ShowView();
return view as DependencyObject;
}
}
そして、オンデマンドでロードできるようにしたいmoduleB(以前はこのコメント行を使用していたので、ここに残しました):
[Module(ModuleName = "ModuleB", OnDemand = true)]
public class ModuleB : IModule
{
private readonly IUnityContainer _container;
private readonly IRegionManager _regionManager;
public ModuleB(IUnityContainer container, IRegionManager regionManager)
{
_container = container;
_regionManager = regionManager;
}
public void Initialize() {
_regionManager.Regions["MainRegion"].Add(new ModuleBView());
this.RegisterViewsAndServices();
// this._regionManager.RegisterViewWithRegion(RegionNames.MainRegion, () => _container.Resolve<MissionProfileView>());
}
protected void RegisterViewsAndServices()
{
_container.RegisterType<Modules.ModuleBView>();
}
}
ここで何が間違っていますか?どのように進めればよいですか?