将WPF项目更改为Prism项目
1.创建一个基于.NetFramework或.NetCore的WPF应用程序。
2.在NuGet管理器中添加 Prism.Dryloc包
3.修改 App.xaml 的基类为PrismApplication
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Prism.DryIoc.PrismApplication
{
protected override Window CreateShell()
{//创建启动页
return Container.Resolve<Window>();
}
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{//注册MVVM视图模型
containerRegistry.Register<MainWindow,ViewModelMainWindow>();
}
}
<prism:PrismApplication x:Class="WpfApp2.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApp2"
xmlns:prism="http://prismlibrary.com/">
<Application.Resources>
</Application.Resources>
</prism:PrismApplication>
浙公网安备 33010602011771号