I’m overriding the OnStartup method as below within my App.xaml.cs. However, once I added the splash screen closing, my main window is never displayed. The debugger reaches the main.Show() line but after this is finished executed, the application closes. Any ideas?
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
SplashWindow splash = new SplashWindow();
splash.Show();
System.Threading.Thread.Sleep(5000);
splash.Close();
MainWindow main = new MainWindow();
main.Show();
}
Because the default value for
ShutdownModeisOnLastWindowClose, so when you close your splash screen the programm exits.You can change this by adding the following code after the call to base.OnStartup
If that still doesn’t work setting it to
OnExplicitShutdownmight work.