第528篇-Prism学习系列4_Hello World(Boot strapper)
本文讲解在Prism中如何以Boot Strapper方式启动程序.
Boot strapper:
class Bootstrapper : UnityBootstrapper { protected override DependencyObject CreateShell() { return this.Container.Resolve<Shell>(); } protected override void InitializeShell() { base.InitializeShell(); App.Current.MainWindow = (Window)this.Shell; App.Current.MainWindow.Show(); } protected override void ConfigureModuleCatalog() { base.ConfigureModuleCatalog(); ModuleCatalog moduleCatalog = (ModuleCatalog)this.ModuleCatalog; moduleCatalog.AddModule(typeof(HelloWorldModule.HelloWorldModule)); } }
Module A:
//public class HelloWorldModule : IModule //{ // private readonly IRegionViewRegistry regionViewRegistry; // public HelloWorldModule(IRegionViewRegistry registry) // { // this.regionViewRegistry = registry; // } // public void Initialize() // { // regionViewRegistry.RegisterViewWithRegion("MainRegion", typeof(Views.HelloWorldView)); // } //} public class HelloWorldModule : IModule { private readonly IRegionManager RegionManager; public HelloWorldModule(IRegionManager iregionmanager) { this.RegionManager = iregionmanager; } public void Initialize() { RegionManager.Regions["MainRegion"].Add(new Views.HelloWorldView()); } }
Demo下载:https://skydrive.live.com/#cid=6B286CBEF1610557&id=6B286CBEF1610557!687