开发者

When Modal Dialog is shown in WPF and a user clicks on the parent window, make the modal dialog flash, blink or shake

开发者 https://www.devze.com 2023-03-24 02:40 出处:网络
New Thought, Maybe I am looking at this totally incorrectly. So Here 开发者_开发知识库is exactly what I am trying to do in case there is another option I am not aware of.

New Thought, Maybe I am looking at this totally incorrectly. So Here 开发者_开发知识库is exactly what I am trying to do in case there is another option I am not aware of.

I have a WPF app, the main window shows a smaller dialog window using ShowDialog(), when a user clicks on the parent window that showed the dialog, I need to make the dialog window, flash, shake or blink.

AresAvatar posted a link that looks like it might be able to use, but is there another option I am not aware of?

My original Question.

Mouse click event when Modal window's parent is clicked in WPF app?

I have a wpf app that shows a modal window using ShowDialog().

I would like to fire an event when the user tries to click the parent window that is now disabled.

Is it possible on the parent to receive a click event when it has shown a modal window? When I attempted this using an interaction trigger, the events never fired on parent window.

Otherwise, what suggestions / options are there.

Thanks


No WPF events are sent under these conditions. The only Windows message I can see that gets sent is WM_WINDOWPOSCHANGING. You could check for that message, and check if the window was disabled when it occurred. Here's a good article on checking WM_WINDOWPOSCHANGING.

Edit: that link seems to be dead. Here's an example on StackOverflow of checking window messages.


I know this is an old question but I'll post my solution in case any one needs it.

Set the dialog.owner prior to calling ShowDialog().

var dialog = new DialogWindow();
dialog.owner = MainWindow;
dialog.ShowDialog();

The result is that clicking on the main window, brings the dialog window to the front and makes the dialog window flash.

0

精彩评论

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