I am using Window.ShowDialog() to open a modal window in my WPF (MVVM) application, but it lets me navigate to other windows using the Windows taskbar (Windows
Setting Topmost to True (Topmost=True) causes the dialog to be on the top of all windows in the system (not only in application).
So you can try to register the event Activated in your main window:
Activated += WindowActivated;
and activate an owner window of the modal dialog every time when another main window of your application become active.
private void WindowActivated(object sender, EventArgs e)
{
Window window = Application.Current.Windows.OfType().FirstOrDefault(p => p != this && !p.IsActive && p.OwnedWindows.Count > 0);
if (window != null)
{
window.Activate();
}
}
This simple hack assumes all your children windows are modal, but you can write a more sophisticated logic.