中显示并且用户单击父窗口时

中显示并且用户单击父窗口时

本文介绍了当模态对话框在 WPF 中显示并且用户单击父窗口时,使模态对话框闪烁、闪烁或摇晃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新想法,也许我完全错误地看待这个.所以这正是我想要做的,以防万一我不知道有另一个选择.

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.

我有一个 WPF 应用程序,主窗口使用 ShowDialog() 显示一个较小的对话框窗口,当用户单击显示对话框的父窗口时,我需要使对话框窗口闪烁、摇晃或闪烁.

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 发布了一个看起来可以使用的链接,但还有其他我不知道的选项吗?

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

我原来的问题.

在 WPF 应用程序中单击 Modal 窗口的父级时的鼠标单击事件?

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

我有一个 wpf 应用程序,它使用 ShowDialog() 显示一个模态窗口.

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.

谢谢

推荐答案

我知道这是一个老问题,但我会发布我的解决方案,以防有人需要它.

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

在调用 ShowDialog() 之前设置 dialog.owner.

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.

这篇关于当模态对话框在 WPF 中显示并且用户单击父窗口时,使模态对话框闪烁、闪烁或摇晃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 14:33