01、BootstrapperShell

  1、将App.xaml中的StartupUri="MainWindow.xaml"删除。

  2、使用NuGet安装Prism.Wpf、Prism.Core、Prism.Unity。

  3、添加类“Bootstrapper”,编辑如下:

 1 using Microsoft.Practices.Unity;
 2 using Prism.Unity;
 3 using System.Windows;
 4 using BootstrapperShell.Views;
 5 
 6 namespace BootstrapperShell
 7 {
 8     public class Bootstrapper : UnityBootstrapper
 9     {
10         protected override DependencyObject CreateShell()
11         {
12             return Container.Resolve<MainWindow>();
13         }
14 
15         protected override void InitializeShell()
16         {
17             Application.Current.MainWindow.Show();
18         }
19     }
20 }

  4、创建文件夹Views,将MainWindow.xaml移动到此文件夹中。

    

  5、修改App.xaml

 1 using System.Collections.Generic;
 2 using System.Configuration;
 3 using System.Data;
 4 using System.Linq;
 5 using System.Threading.Tasks;
 6 using System.Windows;
 7 
 8 namespace BootstrapperShell
 9 {
10     /// <summary>
11     /// App.xaml 的交互逻辑
12     /// </summary>
13     public partial class App : Application
14     {
15         protected override void OnStartup(StartupEventArgs e)
16         {
17             base.OnStartup(e);
18 
19             var bootstrapper = new Bootstrapper();
20             bootstrapper.Run();
21         }
22     }
23 }

 

转载于:https://www.cnblogs.com/bjxingch/articles/9544539.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值