WPF - Unable to shutdown application after adding splash window to the project

113 views Asked by At

I am unable to shutdown my WPF application on closing the main window. Just facing this issue after adding new window (splash screen) to my project. Below is the newly added code in App.xaml.cs

SplashScreen splash = new SplashScreen();
splash.Show();
MainWindow main = new MainWindow();
this.MainWindow = main;
Thread.Sleep(2000);           
splash.Close();
1

There are 1 answers

6
mm8 On

Try to set the Shutdownmode of the App to ShutdownMode.OnMainWindowClose:

ShutdownMode = ShutdownMode.OnMainWindowClose;

Then the app should shutdown when you close main (assuming you actually show it first).