Search code examples
c#wpfstartupmulti-window

How to ShowDialog two windows sequentially with APP.xaml Startup function


private void AppToStart(object sender, StartupEventArgs e)
{           
    var startUpWindow=new StartUpWindow();
    startUpWindow.ShowDialog();
    var mainWindow = new MainWindow();
    mainWindow.ShowDialog();
}

I have wrote these commands to ShowDialog MainWindow after StartUpWindow. But when I close the StartUpWindow instance, the entire application closes. What's wrong with my code? If there is a better way to doing what I want instead of creating an instance and calling his ShowDialog method please tell me.


Solution

  • after i added ShutdownMode="OnExplicitShutdown" in APP.xaml properties , my app closing with Application.Current.Shutdown(); method.