WPF自定义Main函数

第一步:app.xaml.cs里加入以下代码:

        [STAThread]
        public static void Main(string[] args)
        {
            App app = new App();
            app.InitializeComponent();
            app.Run();
        }

第二步:右键App.xaml文件在属性窗口中将“建置動作”(繁體)ApplicationDefinition改为Page

第三步:右键项目名称,选择属性,在属性页面中点击应用程序,将啓始物件(繁体)(默认未设置)切换为App

第四步:保存,重新编译。

註:轉載請說明出處。

http://www.cnblogs.com/RedSky/p/5776625.html

原文地址:https://www.cnblogs.com/RedSky/p/5776625.html