内容简介:在WPF的Tunnel(Preview)路由事件中用MessageBox.Show弹出对话框后,会中断后续的Bubbling事件。根据MSFT的解释是,MessageBox弹出时获取到了焦点,导致路由事件的链断了。相关说明:Hi Fortnum,
在WPF的Tunnel(Preview)路由事件中用MessageBox.Show弹出对话框后,会中断后续的Bubbling事件。根据MSFT的解释是,MessageBox弹出时获取到了焦点,导致路由事件的链断了。
相关说明: MessageBox prevent RoutedEvent routing
Hi Fortnum,
I performed a test based on your sample code and did see the problem on my side.
The reason is that the messagbox takes the focus from the window when it pops up. Thus, the UI elements in the routed event chain won't receive the routed event any more.
As you can see, this behavior is by design. We can only show a modeless window from within the preview mouse related routed event handler. Unfortunately, it doesnt' fit in your case because you must show a modal window to ask the user whether to bubble the routed event chain. My suggestion is to show the messagebox from within the MouseLeftButtonDown event handler of the InnerButton. If the user chooses No, exit the event handler directly. For example:
void InnerButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (MessageBox.Show("Continue the event processing?","Confirmation",MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
// do some work here
....
}
}
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- Linux中断一网打尽(2) - IDT及中断处理的实现
- Kernel trace tools(一):中断和软中断关闭时间过长问题追踪
- Java中断机制
- 展开中断或忽略的序号
- haskell – 让重命名功能中断代码
- Cloudflare 接口服务中断故障复盘与思考
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
如何构建敏捷项目管理团队
丽萨·阿金斯 / 徐蓓蓓、白云峰、刘江华 / 电子工业出版社 / 2012-6 / 49.00元
《敏捷项目管理系列丛书•PMI-ACPSM考试指定教材•如何构建敏捷项目管理团队:ScrumMaster、敏捷教练与项目经理的实用指南》结合作者的亲身经历告诉读者如何建立一个高性能的敏捷项目管理团队,以及最终成为一名优秀的敏捷教练。作者将敏捷教练定义为导师、协助者、老师、问题解决者、冲突领航员、协作指挥者,正是这种不同角色之间的细微区别才使敏捷教练的工作富有深度。《敏捷项目管理系列丛书•PMI-A......一起来看看 《如何构建敏捷项目管理团队》 这本书的介绍吧!