WPF如何设置启动窗口

    在做系统时,我们想在启动时显示自己想显示的界面,和Winform不同的是它有两种方法

1、在App.xaml中

<Application x:Class="WpfApp1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:WpfApp1"
             Startup="Application_Startup">
    <Application.Resources>

2、在App.xaml上面的Starup中

<Application x:Class="WpfApp1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:WpfApp1"
             Startup="Application_Startup">
    <Application.Resources>

定义一个启动函数在后台代码中对该函数进行修改

private void Application_Startup(object sender, StartupEventArgs e)
        {
            DialogFrm.Login login = new DialogFrm.Login();
            login.Show();
        }

  

原文地址:https://www.cnblogs.com/wjr0117/p/8572461.html