Hello devz,

It happens sometimes with WPF that a popup or a MessageBox is hidden and can block the whole application.

To avoid this, just do the following:

The Application.Current.MainWindow is the solution…

But please pay attention that this parameter can be different! Indeed it’s an implementation of IWin32Window that will own the modal dialog box. So it will not be always Application.Current.MainWindow…

For more info please look at the MSDN post: here.

 

UPDATE:

But actually even in this case, we could have issues…

This is the correct way of doing it.

I created a MessageBoxWrapper that can manage the UI Dispatcher:

Usage:

Happy coding! 🙂