启用父操作时,WPF TouchUp不会触发

时间:2013-03-17 09:44:30

标签: wpf touch

我有一个Canvas,有一个子控件。子控件接收所有PreviewTouchDown和PreviewTouchUp事件 - 但在Canvas上启用Manipulation(IsManipulationEnabled = true)后,只有“down”事件会在子对象上触发,但TouchUp和PreviewTouchUp事件不会触发在所有..

有什么想法在这里发生了什么?

2 个答案:

答案 0 :(得分:4)

您还需要在子元素上将IsManipulationEnabled设置为true


触摸和操纵事件之间的关系在Input Overview / Touch and Manipulation触摸和操纵事件之间的关系部分进行了解释:

  

UIElement始终可以接收触摸事件。当。。。的时候   IsManipulationEnabled属性设置为true,UIElement可以接收   触摸和操纵事件。如果TouchDown事件不是   处理(即Handled属性为false),操作   逻辑捕获元素的触摸并生成操作   事件。如果TouchDown事件中的Handled属性设置为true,   操纵逻辑不会生成操纵事件。该   下图显示了触摸事件和触摸事件之间的关系   操纵事件。

触摸和操纵事件

Touch and manipulation events

答案 1 :(得分:2)

我知道它已经一岁了,但这可能对某人有所帮助: 对于解决方法,您可以捕获" Stylus tap"如果父元素具有IsManipulationEnabled = true

,则事件就好了
....

MyChildElement.StylusSystemGesture += MyChildElement_StylusSystemGesture;

....

void MyChildElement_StylusSystemGesture(object sender, StylusSystemGestureEventArgs e)
    {
        if (e.SystemGesture == SystemGesture.Tap)
            //Do something
    }