$ cat "

Displaying Modal Dialogs with WPF


In WPF you can show a modal dialog with the ShowDialog method, just as in WinForms. However, it does not behave quite right. For example, if you display a modal dialog, then swich to another application, and switch back to you application the main form will be shown and not the modal dialog.

To get the expected behaviour you have to set the Owner property of the dialog before calling ShowDialog():

var dialog = new FooDialog();
dialog.Owner = this;

This makes the modal dialog the topmost window of the application.

Written by Erik Öjebo 2009-08-13 12:54