在C#WPF中处理鼠标事件 [英] Handling mouse events in C# WPF

查看:446
本文介绍了在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中处理鼠标事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆