大家好, 我是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中处理鼠标事件
发布评论