在C#WPF中处理鼠标事件

编程入门 行业动态 更新时间:2024-10-11 17:24:44
本文介绍了在C#WPF中处理鼠标事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我是Wpf的新手,隧道和鼓泡技术有问题.我有一个带有文本块的网格.文本块继承了网格的路由鼠标事件.而且我为网格实现了自己的双击事件.我的问题是,当我使用网格在应用程序中触发了双击事件时,如果双击TextBlock,则双击事件会触发两次,如果单击其他会触发一次的事件,则双击事件会触发两次.我如何才能阻止它触发两次.任何帮助表示赞赏. 谢谢, Mike.

Hi All, I am new to Wpf and I have problem with the Tunneling and Bubbling technique. I have a grid with a textblock inside it. The textblock inherits the routed mouse events for the grid. And i have my own double click event implemented for the grid. My problem is when i have my double click event triggered in a application using my grid, the double click event triggers twice if i double click on the TextBlock, if i click else where it triggers once. How can i stop it from triggering twice. Any help is appreciated. Thanks, Mike.

推荐答案

为了将RoutedEvent标记为已处理,可以设置RoutedEventArgs 类.

In order to mark a RoutedEvent as handled, you can set the Handled property of the RoutedEventArgs class.

您可以在MSDN主题中看到有关 RoutedEventArgs的示例和更多说明. .Handled 属性.

You can see an example and more explanation in the MSDN topic about the RoutedEventArgs.Handled property.

更多推荐

在C#WPF中处理鼠标事件

本文发布于:2023-11-12 13:19:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581620.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:鼠标   事件   WPF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!