0
votes

I'm using ShowDialog (on a System.Windows.Window) to show a user a confirmation style dialog window. I perform this from a system tray menu option. My problem is that its launching itself hidden behind under windows. If I use TopMost its fine in terms of bringing it to the users attention but using TopMost is too intrusive in other ways. I don't want to force the dialog to always be ontop of other windows.

Before calling ShowDialog I've tried all manner of options such as Focus, Activate, BringIntoView to try bring the dialog to the users attention but to no avail. Have I any other option but to use TopMost? I do want to keep the modal behavior of the dialog.

1
you can use setwindowpos and specify the Z-order... What is it that you're trying to accomplish exactly?Scott Solmer
When launched I want the dialog to appear above all other windows. If they bring another window (e.g their outlook) over the dialog window it should then go behind that windowuser48408
Okay and what's wrong with setting TopMost? Just set it true, then false.Scott Solmer
As I said its too intrusive in the sense you can't move any other window over it. I figured it out in the answer I'm going to supply now. Thanks anywayuser48408
Please post your solution as the answer to your own question. That way future readers can benefit from this post.Scott Solmer

1 Answers

0
votes

The crux of the problem I was having was that setting window.Activate before calling window.ShowDialog had no effect (nor did focus, etc). Instead, before calling ShowDialog I hook up an event handler to the ContentRendered event and activate in then it has the desired effect of bringing the window directly to the front but still allowing users drag other windows over it.

window.ContentRendered += (sender, eventArgs) => window.Activate();
window.ShowDialog();