WPF:设置自定义 Main 入口

1.设置 App.xaml 属性“生成操作”为 Page

2.设置应用程序启动页(或窗口)

<Application x:Class="iDemo.MutexDemo.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:iDemo.MutexDemo"             
             StartupUri="MainWindow.xaml">
    <!--设置启动页(或窗口)属性:StartupUri-->
    <Application.Resources>

    </Application.Resources>
</Application>

3.新建 Program 入口类

public static class Program
{
    [STAThread]
    private static int Main(string[] args)
    {
        var app = new App();
        app.InitializeComponent();
        var result = app.Run();
        return result;
    }
}
posted @ 2022-01-10 09:57  2324736194  阅读(184)  评论(0编辑  收藏  举报