为WPF项目添加Program.cs

1、新增Program.cs文件;

==========================

using System;
using System.Windows;

namespace WpfApp2
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
WpfApp2.App app = new WpfApp2.App();
app.InitializeComponent();
MainWindow windows = new MainWindow();
app.MainWindow = windows;
app.Run();
}
}
}

==========================

2、设置启动对象为Program.cs

项目右键 -> 属性 -> 启动对象

 

posted @ 2021-03-02 14:23  hxqmw  阅读(1265)  评论(0)    收藏  举报