我的 shell 窗口中有一组选项卡,其中一个主要区域是 contentcontrol。I also have four modules that I want to load on demand when a certain tab is selected. So when tab1 is selected I want to load moduleA, when tab2 is selected I want to load ModuleB, etc. The first module loads on when the application starts. 问题是当我更改选项卡时没有任何反应。没有错误很难。我正在使用此版本的 prism Composite Application Guidance for 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;
}
}
还有我希望能够按需加载的模块B(我曾经使用此注释行,这就是我将其留在这里的原因):
[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>();
}
}
我在这里做错了什么?我应该如何进行?