棱镜模块加​​载为窗口

时间:2017-04-10 14:53:03

标签: c# prism

是否可以将带有Prism和Unity bootstrapper的加载模块作为窗口而不是视图?

File Bootstrapper.cs

class Bootstrapper : UnityBootstrapper
{

    protected override DependencyObject CreateShell()
    {
        return Container.Resolve<MainWindow>();
    }

    protected override void InitializeShell()
    {
        Application.Current.MainWindow.Show();
    }

    protected override void ConfigureModuleCatalog()
    {
        var zeroModule = typeof(ZeroModule);
        ModuleCatalog.AddModule(new ModuleInfo()
        {
            ModuleName = zeroModule.Name,
            ModuleType = zeroModule.AssemblyQualifiedName,
            InitializationMode = InitializationMode.OnDemand
        });
    }

}
文件视图/ MainWindow.cs中的

_moduleManager.LoadModule("ZeroModule");

File ZeroModule.cs

public class ZeroModule : IModule
    {
        IRegionManager _regionManager;
        public ZeroModule(RegionManager regionManager)
        {
            _regionManager = regionManager;
        }

        public void Initialize()
        {
            _regionManager.RegisterViewWithRegion("MainRegion", typeof(MainView));
        }
    }

感谢您的回答

0 个答案:

没有答案