wpf prism框架(7.2) Module篇

将Prism.Wpf更新至7.2版本

新增一个Class Library作为一个Mudule,在Module下添加Views文件夹,Views文件夹里添加UserControl ViewC,再添加一个类TestClass,如图:

wpf prism框架(7.2) Module篇

TestClass 继承IModule接口:

 public class TestClass : IModule
    {
        public void OnInitialized(IContainerProvider containerProvider)
        {
            var regionManager = containerProvider.Resolve<IRegionManager>();
            regionManager.RegisterViewWithRegion("Test", typeof(ViewC));
        }

        public void RegisterTypes(IContainerRegistry containerRegistry)
        {

        }
    }

主窗体加载Module:

App.xaml.cs

 public partial class App : PrismApplication
    {
        protected override Window CreateShell()
        {
            return Container.Resolve<MainWindow>();
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {

        }
protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
        {
            moduleCatalog.AddModule<TestModule.TestClass>();
        }
        
    }

MainWindow.xaml:

<ContentControl Grid.Column="2" prism:RegionManager.RegionName="Test" />

 

wpf prism框架(7.2) Module篇

上一篇:C#协变和逆变


下一篇:windows server 2016 远程桌面mstsc DPI(更改文本、应用和其他项目大小) 设置