开发者

C#/WPF, how to make a window (created with Window.ShowDialog()) title bar blink when clicking its parent window (like MessageBox does)?

I'm trying to create a custom MessageBox by using a WPF Window that is c开发者_JAVA百科alled 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!


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();


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜