Iain M Norman Iain M Norman - 1 year ago 135
C# Question

How do I focus a modal WPF Window when the main application window is clicked

I have my MainApplication Window that launches a new Window with .ShowDialog() so that it is modal.

UploadWindow uploadWindow = new UploadWindow();

Now users are often leaving this window open and it can get lost under other windows. When the MainApplication is clicked you get an error-like beep and are unable to interact with it, so the modal window is blocking properly as expected, but it would be nice if the modal window was focused at this point to show the user it was still open.

Currently it just looks as if the MainApplication window has locked up.

Answer Source

Try setting the dialog's owner:

var uploadWindow = new UploadWindow();
uploadWindow.Owner = this;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download