emanon

I wanted to display a splash window that loaded in some data prior to the Main Window of my application opening. I did the following and the splash window ran fine but my MainWindow never runs.

If I place the App constructor after the SplashLoader runs, everything works fine though. Any idea what happens to the Application class when it is created before SplashLoader that would cause it to stop working

[STAThread()]

public static void Main()

{

App app = new App();

SplashLoader sp = new SplashLoader();

sp.ShowDialog();

MainWindow w = new MainWindow();

app.Run(w);

}



Re: Windows Presentation Foundation (WPF) Application.Run Unexpected behavior

Chango V. - MSFT

Look at Application.ShutdownMode. I guess the application quits after the splash window is closed.






Re: Windows Presentation Foundation (WPF) Application.Run Unexpected behavior

emanon

Yeah, you are right. If I specify:


app.ShutdownMode =
ShutdownMode.OnExplicitShutdown;

It will work. Seems wierd that this would be necessary to do when I had never called app.run yet or set its MainWindow to the splash dialog, but it does work.

Thank you for your help. I assume I will have to call app.Shutdown() on my MainWindow's close handler and all will be well.