在做系統時,我們想在啟動時顯示自己想顯示的界面,和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(); }