如何在Visual Studio 2019中创建.Net Core WPF工程
打开Visual Studio 2019,选择Create a new project

选择WPF App(.Net Core)

输入项目名称和位置,单击Create

这样我们就创建好了一个WPF工程


工程文件说明
Dependencies
当前项目所使用的依赖库(包括引用的nuget包、系统框架、COM组件等)
说明:
不同于.Net Framework的WPF工程,我们看不到引用了哪些GAC中的组件。实际上在Microsoft.Windows.Desktop.App.WPF框架中已经引用了WPF所需的全部组件。
我们找到.Net Core的安装目录,可以看到系统定义了一些框架

打开**"dotnet\packs\Microsoft.WindowsDesktop.App.Ref\3.1.0\data\PlatformManifest.txt"**
可以看到

其中Profile指的是当前使用的哪一套配置文件。
如果我们想在WPF工程中引用Winform的类库
打开项目的csproj文件
添加
1 <UseWindowsForms>true</UseWindowsForms>

App.xaml
App.xaml是应用程序的声明性起点。程序的主窗体在这里指定。
App.xaml.cs
App.xaml的后台代码文件,它扩展了Application类。在这里可以对程序的重要事件进行处理。如未经处理的异常,程序启动等等。
System.Windows.Application类是封装 WPF 应用程序特定功能的类,其中包括以下内容:
-
应用程序生存期: Activated、Current、Deactivated、DispatcherUnhandledException、Exit、Run、SessionEnding、Shutdown、ShutdownMode、Startup。
-
应用程序范围窗口、属性和资源管理: FindResource、GetContentStream、GetResourceStream、LoadComponent、MainWindow、Properties、Resources、StartupUri、Windows。
-
命令行参数和退出代码处理: Application.Startup、Application.ExitApplication.Shutdown。
-
导航
AssemblyInfo.cs
在.Net Framework的WPF程序中,该文件用于设置程序集信息。
在.Net Core中,程序集信息被移至 工程->属性->包选项下

MainWindow.xaml/MainWindows.xaml.cs
系统创建的默认主窗口和主窗口的后台代码文件