Main window disappears behind other application's windows after a sub window uses ShowDialog on a third window
This is a pretty annoying WPF bug, I never did find the flaw in the code that causes it but there's a heckofalot of "gotta figure this out" comments in the source code that deals with focusing. Just a workaround, a less than ideal one, you can solve it by explicitly giving the focus to the owner when the window is closing. Copy/paste this code in your SubWindow class;
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) {
base.OnClosing(e);
if (!e.Cancel && this.Owner != null) this.Owner.Focus();
}