WPF插件化开发框架Prism学习-01-BootstrapperShell
Prism插件化开个人笔记:
1.是什么:首先第一个实例学习了prism这个插件框架,可以支持在WPF启动时,引入它自己的“容器”的概念,一般WPF启动入口窗体可以通过直接new一个窗体对象来指定启动时打开的窗体,prism是通过实现PrismBootstrapperBase抽象类的CreateShell,初始化一个程序壳,打到启动一个窗口的目的
2.干什么:引入容器的方式来启动应用程序窗体
3.举例:
新建WPF项目(我这里是.net core3.1版本的 wpf)
安装nuget:Prism.Unity
App.xaml入口程序
using System.Windows; public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var bootstrapper = new Bootstrapper(); bootstrapper.Run(); } } Bootstrapper using Unity; using Prism.Unity; using BootstrapperShell.Views; using System.Windows; using Prism.Ioc; class Bootstrapper : PrismBootstrapper { protected override DependencyObject CreateShell() { return Container.Resolve<MainWindow>(); } protected override void RegisterTypes(IContainerRegistry containerRegistry) { } }
浙公网安备 33010602011771号