0
votes

i am wondering if there are any drawbacks, in showing a modal mainwindow in a WPF application with .ShowDialog() instead of Show().

This is the usual way to manually show the mainwindow:

private void Application_Startup(object sender, StartupEventArgs e)
{
    // the usual way to show the mainwindow
    new MainWindow().Show();
}

This is what i want do to:

private void Application_Startup(object sender, StartupEventArgs e)
{
    // what i want to do
    new MainWindow().ShowDialog();
}

I want to start a WPF app from a 3. party application addon, that can call static methods from external .NET DLLs. So i build a DLL as an addon that starts my WPF app inside a new AppDomain. This works fine as long the user does not do anything in the 3. party app, otherwise it will crash. I can prevent this, if i show the mainwindow of my app as a modal dialog, because this blocks the 3. party app window.

1

1 Answers

1
votes

Well, a potential drawback is the fact that the ShowDialog() method doesn't return until the dialog window has been closed which means that you won't be able to interact with the "previous" window during the meantime.

But in your case, this seems to be exactly what you want. So since it works the way you want in your specific scenario, I would stick with using ShowDialog().