WPF事件处理 [英] WPF Event Handling

查看:112
本文介绍了WPF事件处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我一直在使用silverlight 3.0开发拖放应用程序。

I have been developing an drag and drop application with silverlight 3.0.

当我点击(mouseLeftButtonDown)时,事件被激活了Label-> Canvas(内部)一))
和当我向上鼠标时,事件像canvas(innerone)一样被触发 - > canvas(outerone)

when i click (mouseLeftButtonDown), the event got fired for Label->Canvas(inner one)
and When i mouse up the event gets fired like canvas(innerone) -> canvas(outerone)

我想要做的是,当用户点击标签控件时,单击标签并在画布上单击时,只应触发一次标签控件的mouseButtonDownEvent )同样应该发生应该为
画布控件调用mouseLeftButtonDown(仅内部一个)..

What i want to do is, when user clicks on label control the mouseButtonDownEvent should be fired only once for label control when clicked on label and when clicked on canvas(inner one) the same should happen that mouseLeftButtonDown should be called for canvas control(inner one only)..

 

确保控件注册后有以下事件......

Make sure that the controls are registred with following events...

Canvas - > mouseLeftbuttonDown - > FunctionOne(..,...)

Canvas --> mouseLeftbuttonDown-->FunctionOne(..,...)

标签 - > mouseLeftButtonDown - > FunctionOne(..,..)//这意味着两者都注册了相同的事件。

Label--> mouseLeftButtonDown -->FunctionOne(..,..) // This means that both are registred with the same event.

推荐答案

你可以设置eventArgs.Handled = true;在每个事件处理程序中,事件将仅被触发到树中的第一个事件处理程序。
You can set eventArgs.Handled = true; in each event handler, so the event will be fired to only the first event handler in the Tree.


这篇关于WPF事件处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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