look into App.xaml
remove StartupUri="MainWindow.xaml"
add Startup="Application_Startup"
new event Handler
<Application x:Class="YourProject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="Application_Startup">
form code behind App.xaml.cs create Application_Startup like...
private void Application_Startup(object sender, StartupEventArgs e)
{
//add some bootstrap or startup logic
var identity = AuthService.Login();
if (identity == null)
{
LoginWindow login = new LoginWindow();
login.Show();
}
else
{
MainWindow mainView = new MainWindow();
mainView.Show();
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…