wpf prism框架(7.2) Module篇

2021-03-11 14:35

阅读:373

标签:img   public   color   log   class   var   更新   div   catalog   

将Prism.Wpf更新至7.2版本

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

技术图片

TestClass 继承IModule接口:

 public class TestClass : IModule
    {
        public void OnInitialized(IContainerProvider containerProvider)
        {
            var regionManager = containerProvider.Resolve();
            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();
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {

        }
protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
        {
            moduleCatalog.AddModule();
        }
        
    }

MainWindow.xaml:

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

 

wpf prism框架(7.2) Module篇

标签:img   public   color   log   class   var   更新   div   catalog   

原文地址:https://www.cnblogs.com/dangnianxiaoqingxin/p/12636008.html


评论


亲,登录后才可以留言!