I have encountered a very easily reproduced and exceedingly frustrating bug in WPF when using "nested" dialogs (i.e. windows "owned" by the window that opens them). Here is a quick description of a situation that causes the problem:
MainAppWindow opens WindowA modelessly. WindowA is owned by MainAppWindow.
WindowA opens WindowB modelessly (or modally, doesn't see to matter). WindowB is owned by WindowA.
Close WindowB - everything is as expected: WindowA is on top of MainAppWindow and app is in foreground of desktop.
Close WindowA - WindowA closes but MainAppWindow is dropped to background of desktop (i.e. behind any other open applications).
The following simple application demonstrates the problem. Just click construct 2 nested dialogs them close them in reverse order. You will need to have another application like notepad in the background so that you can see the WPF app main window
get dropped behind it.
- create a new WPF application in Visual Studio (I'm using 2008, sp1) and copy/paste the following code for the Window1.xaml and Window1.xaml.cs files. I have been able to reproduce this issue on XP, Win7 and Vista.
View Complete Post