我有一套选项卡在我的shell窗口和一个主要区域whicxh是一个内容控件。当选择某个选项卡时,我还有四个模块需要按需加载。所以,当选择tab1时,我想加载moduleA,当选择tab2时,我想加载ModuleB等。第一个模块在应用程序启动时加载。问题是,当我改变标签没有任何反应。没有错误艰难。我使用这个版本的棱镜复合应用程序指南WPF和Silverlight的 - 2009年10月PRISM和WPF如何添加一个模块按需
我尝试这样的做法:
壳牌:
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>();
}
}
我在这里做错了什么?我应该如何继续?
我有几乎相同的场景。来自我的问题+1 – autonomatt 2010-06-30 17:12:48