1.安装包管理器

# 搜索框内需要填入↓
"id=Microsoft.NETCore.App"
"id=Microsoft.WindowsDesktop.App.Ref"

2.代码
void Main()
{
var app = new System.Windows.Application();
var mainWindow = new System.Windows.Window
{
Title = "Simple WPF Program",
Width = 300,
Height = 200,
WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen
};
var button = new System.Windows.Controls.Button
{
Content = "Click Me!",
HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
VerticalAlignment = System.Windows.VerticalAlignment.Center
};
button.Click += (sender, e) => System.Windows.MessageBox.Show("Button Clicked!");
mainWindow.Content = button;
app.Run(mainWindow);
}
3.效果
