Answered by:

Common Dialogs aren't behaving like truly modal dialoges

Question

Hi. If I show the OpenFileDialog after while I have a modeless child WPF Window up, I can't click on the main Window but I can click and interact with the other child Window. Is there a way to make the common dialog act truly modal? Can someone
also show me how to get its handle?

Answers

Here is the Helper class along with an implementation, i should mention that on further testing the user can still move other windows but they cannot do anything in them and all windows of the application will always be behind the dialog. In order to prevent
the window title bar selection from moving the window you will probably need to get into some interop calls and handlers using user32.dll. You should be able to extend what is provided here if you need to.

Here is the Helper class along with an implementation, i should mention that on further testing the user can still move other windows but they cannot do anything in them and all windows of the application will always be behind the dialog. In order to prevent
the window title bar selection from moving the window you will probably need to get into some interop calls and handlers using user32.dll. You should be able to extend what is provided here if you need to.

That is a good observation, during my original testing I did not "need" to reset the MainWindow property back to gain the desired functionality, but its possible there could be some unintended side effects if you did not set it back. I would recommend keeping
a local variable of the original value and set it back in the UnhookWindowsActivatedEvents method.

This also brings up another possible issue opening a modal dialog from within another modal dialog, in this case when you close the second child window the first modal dialog
would probably lose its modal functionality, this code could definitely be improved to handle this situation.