启用父操作时 WPF TouchUp 不触发
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15459384/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WPF TouchUp not firing when parent manipulation is enabled
提问by Jaska
I have a Canvas, with one child control. The child controls receives all PreviewTouchDown and PreviewTouchUp events fine - but after enabling Manipulation (IsManipulationEnabled= true) on the Canvas, only the "down" events get fired on child object, but the TouchUp and PreviewTouchUp events doesn't fire at all..
我有一个画布,有一个孩子控制。子控件可以很好地接收所有 PreviewTouchDown 和 PreviewTouchUp 事件 - 但是在IsManipulationEnabledCanvas 上启用 Manipulation ( = true) 后,只有“down”事件在子对象上被触发,但 TouchUp 和 PreviewTouchUp 事件根本不会触发..
Any ideas what's going on here?
任何想法这里发生了什么?
回答by Clemens
You need to set IsManipulationEnabledto trueon the child element, too.
您也需要在子元素上设置IsManipulationEnabled为true。
The relationship between touch and manipulation events is explained in Input Overview / Touch and Manipulation, section The Relationship Between Touch and Manipulation Events:
触摸和操纵事件之间的关系在输入概述/触摸和操纵,触摸和操纵事件之间的关系部分中进行了解释:
A UIElement can always receive touch events. When the IsManipulationEnabled property is set to true, a UIElement can receive both touch and manipulation events. If the TouchDown event is not handled (that is, the Handled property is false), the manipulation logic captures the touch to the element and generates the manipulation events. If the Handled property is set to true in the TouchDown event, the manipulation logic does not generate manipulation events. The following illustration shows the relationship between touch events and manipulation events.
UIElement 始终可以接收触摸事件。当 IsManipulationEnabled 属性设置为 true 时,UIElement 可以接收触摸和操作事件。如果未处理 TouchDown 事件(即 Handled 属性为 false),则操作逻辑会捕获对元素的触摸并生成操作事件。如果在 TouchDown 事件中将 Handled 属性设置为 true,则操作逻辑不会生成操作事件。下图显示了触摸事件和操作事件之间的关系。
Touch and manipulation events
触摸和操作事件


回答by JavierIEH
I know its a year old, but this might help someone: For a workaround, you can capture "Stylus tap" events just fine if the parent element has IsManipulationEnabled = true
我知道它已经有一年了,但这可能对某人有所帮助:对于解决方法,如果父元素具有 IsManipulationEnabled = true,您可以捕获“Stylus tap”事件就好了
....
MyChildElement.StylusSystemGesture += MyChildElement_StylusSystemGesture;
....
void MyChildElement_StylusSystemGesture(object sender, StylusSystemGestureEventArgs e)
{
if (e.SystemGesture == SystemGesture.Tap)
//Do something
}

