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

走远了吗. 提交于 2019-12-11 03:38:47

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/6900169/when-modal-dialog-is-shown-in-wpf-and-a-user-clicks-on-the-parent-window-make-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!