views:

46

answers:

2

Hello everyone!

I'm trying to create a custom MessageBox by using a WPF Window that is called with ShowDialog().

So far, I've managed to implement everything, except for one thing.

As you know, when you use MessageBox.Show("text"); you cannot set the focus or click the parent window (the one that called the MessageBox). If you do try to click the parent window, the MessageBox will blink briefly in order to alert you that you must close if first.

Windows created with Window.ShowDialog();, however, do not show that behavior. In fact, while you cannot set the focus to the parent window, the child (called with ShowDialog()) will never blink briefly.

My question is, is there any way to implement that in WPF? I've been searching for an answer but I must admit, I am stumped.

Thanks everyone!

+3  A: 

You need to set the Owner of the modal window correctly, e.g. using the following code from within the owning window:

Window win = new SomeModalWindow();
win.Owner = this;
win.ShowDialog();
0xA3
So simple... Well, now I feel stupid! Thanks a lot!
Ze Pedro
+1  A: 

You would have to set Owner property of the child Window to the parent Window. See the MSDN Documentation here.

Coding Gorilla