在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

WPF中MsgBox的弹出会中断路由事件的传递相关推荐

  1. iOS下Html页面中input获取焦点弹出键盘时挡住input解决方案

    iOS下Html页面中input获取焦点弹出键盘时挡住input解决方案 参考文章: (1)iOS下Html页面中input获取焦点弹出键盘时挡住input解决方案 (2)https://www.cn ...

  2. iOS下Html页面中input获取焦点弹出键盘时挡住input解决方案—scrollIntoView()

    iOS下Html页面中input获取焦点弹出键盘时挡住input解决方案-scrollIntoView() 参考文章: (1)iOS下Html页面中input获取焦点弹出键盘时挡住input解决方案- ...

  3. Angular2项目中浏览器拦截弹出窗口的解决方法

    Angular2项目中浏览器拦截弹出窗口的解决方法 为什么把项目是Angular2的放到了前边? 因为正常也页面网上已经很多解决方案.请自行百度或Google. 现象:当window.open为用户触 ...

  4. java鼠标右击出现选择窗口_java菜单代码 java中鼠标右击弹出菜单怎样实现

    帮忙给一个java菜单栏例子的源代码 给你个小例子,已经添加注释了.自己运行下看看效果,满意的话记得结贴子. import java.awt.BorderLayout; import java.awt ...

  5. ASP.NET中WEB上弹出消息框的N种方法(为了以后方便,转了很多网友的文章!希望不会介意)...

    ASP.NET中WEB上弹出消息框的N种方法 第一个确定之后跳转到另一页面,第二个确定之后返回前一页 Response.Write("<script langage='javascri ...

  6. Android中EditText优先弹出数字输入法

    Android Android中EditText优先弹出数字输入法 项目中一个EditText输入数字的频率较高,但是汉字和英文的输入也偶有需要,直接在xml文件将inputType设置为number ...

  7. 解决微信小程序IOS中使用picker弹出内容和手机软键盘重叠的问题

    解决微信小程序IOS中使用picker弹出内容和手机软键盘重叠的问题 项目需求: 一个信息提交页面:有input输入框,有picker选择器 遇到的问题: 点击input输入框时,手机自动弹出键盘,但 ...

  8. 为企业微信“服务商应用”更改微信插件中的消息弹出样式

    一. 背景 1. 企业微信"服务商应用" 企业微信的"自建应用"类目中,可以选择添加完全自建的应用,也可以选择添加服务商提供的代开发应用. 代开发应用是由企微认 ...

  9. 计算机窗口弹不出来桌面怎么弄,怎么在电脑中设置不再弹出程序的广告窗口

    怎么在电脑中设置不再弹出程序的广告窗口 有的小伙伴在使用电脑过程中,总是会收到各种软件程序的弹出广告窗口,觉得特别打扰电脑的使用,因此想要设置不再弹出广告窗口,但是却不知道如何设置,那么小编就来为大家 ...

最新文章

  1. java中标识符,关键字,数据类型
  2. 引入三方库_关于使用第三方库、代码复用的一些思考
  3. 因未发项目奖金,一名程序员决定删代码泄愤
  4. 配置tomcat容器的access.log访问日志
  5. 2018\National _Java_A\1.三角形面积
  6. note header initialization discussion
  7. LeetCode 372. 超级次方(快速幂)
  8. 【CUDA开发】 Check failed: error == cudaSuccess (8 vs. 0) invalid device function
  9. HTML中嵌入FLV视频文件
  10. 带瀑布流的电钢琴_你没有看错 这个Find智能钢琴它会自己弹琴
  11. 计算机三级网络技术(精简)
  12. h5移动端开发之禁用微信浏览器字体大小设置
  13. Jxls使用模版导出excel表格公式无法自动计算失效解决
  14. 用c语言把图像转成jpg格式,图像格式转换之BMP格式转换为JPG格式(示例代码)
  15. 工欲善其事,必先利其器篇-高效实现右滑退出功能
  16. ECCV2020:论文解读《Synthesize then Compare: Detecting Failures and Anomalies for Semantic Segmentation》
  17. python时间模块 datetime (datetime、timedelta和timezone部分)
  18. Visual Studio 2008 官方破解版
  19. win10安装的es设置自启动时报错Failed starting ‘elasticsearch-service-x64‘ service
  20. joomla后台拿shell

热门文章

  1. Flowable 实现【选择下一步流程审核人】
  2. 免费格式转换器有哪些?这几款一定要试试
  3. STM32F1读取MLX90632非接触式红外温度传感器
  4. oninput和onchange区别
  5. 【java】RGB颜色转换为16进制颜色
  6. Bioinfomatic
  7. 广州“全能”社保卡计划年底发放
  8. vue 常见的新增、编辑、查看公用同一个页面
  9. 小程序开发调用微信支付以及微信回调地址配置
  10. Java解析Base64编码为图片