简体   繁体   English

滑动(轻拂)父级时,防止子级视图上的Click事件。 WinPhone8.1

[英]Prevent Click events on child view while swiping(flicking) parent. WinPhone8.1

I have canvas with listbox inside it. 我的画布里面有列表框。 each child element of listbox sets eventhandler for Click event. 列表框的每个子元素都会为Click事件设置事件处理程序。 On canvas I set eventhandlers for 在画布上,我为设置了事件处理程序

ManipulationStarted="canvas_ManipulationStarted"       
ManipulationDelta="canvas_ManipulationDelta"
ManipulationCompleted="canvas_ManipulationCompleted"

My code for swiping works perfect accept one thing, it fires Click eventhandler before ManipulationCompleted eventhandler. 我的刷卡代码可以完美地接受一件事,它会在ManipulationCompleted事件处理程序之前触发Click事件处理程序。

But for example listbox in the same time scrolls perfectly and do not fire Click event. 但是例如列表框在同一时间滚动完美,并且不触发Click事件。

So basically what I need is to handle manipulation events in same way listbox do. 因此,基本上我需要以与列表框相同的方式处理操作事件。

If this condition is true: 如果满足此条件:

private void canvas_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{ 
     e.DeltaManipulation.Translation.X > [some value]
     ....
}

I need to disable firing Click event on any child element of canvas, doesn't matter if it is inside listbox or not. 我需要在画布的任何子元素上禁用触发Click事件,无论它是否在列表框中都无关紧要。

Why are you setting click handlers if you don't want them to fire? 如果不想触发点击处理程序,为什么还要设置?

Click fires on pointer pressed, so there's no way to tell if the user wanted to Click or to start a manipulation. 单击会在按下指针时触发,因此无法判断用户是否要单击或开始操作。 You'll need to either decide based on the location clicked or a later event if you want to differentiate between "clicks" and swipes. 如果要区分“点击”和“滑动”,则需要基于单击的位置或以后的事件来决定。

Instead of Click you can handle the Tap gesture along with the manipulation events. 除了点击之外,您还可以处理点击手势以及操纵事件。 Since Tap fires on the pointer released the manipulation system will fire it if the user tap and releases in one spot and it will trigger the manipulations if the user presses and moves the pointer. 由于轻击会在释放指针时触发,因此如果用户轻按并释放一个点,操纵系统就会触发它,如果用户按下并移动指针,它将触发操纵。

See How to handle manipulation events for Windows Phone 8 for more details. 有关更多详细信息,请参见如何处理Windows Phone 8的操作事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 'child' ' 不是该父级的子控件。 在继承的按钮上 - 'child' ' is not a child control of this parent. on inherited buttons WinPhone 8.1 TimeSpan格式输出 - WinPhone 8.1 TimeSpan formatting output 使用Xamarin.Forms和Caliburn.Micro的WinPhone 8.1项目很难创建视图 - WinPhone 8.1 project with Xamarin.Forms and Caliburn.Micro failes to create view 如何通过关系子/父的 2 个字段排序。 对其进行排序以使子项在排序列表中跟随其父项? - How to order by 2 fields with relation child/parent. Sort it so that child items follow their parents in the sorted list? WinPhone 8.1上的Xaml正常运行,但被IDE显示为错误 - Xaml on WinPhone 8.1 working but shown as error by the IDE Caliburn Micro 2和WinPhone 8.1:后退按钮未绑定? - Caliburn Micro 2 and WinPhone 8.1: Back button not bound? WinPhone 8.1 | 强制更改XAML布局 - WinPhone 8.1 | Force xaml layout change WP8.1 Click事件为ListView ItemTemplate中的子元素忽略了ClickClick事件 - WP8.1 Click event for child element in ListView ItemTemplate while ignoring ItemClick event 关于在winphone 8.1 RT中的ContentDialogResult中的换行文本 - about wrap text in ContentDialogResult in winphone 8.1 RT 如何将子用户控件中的按钮链接到父级。 C#/ WPF - How to link buttons in child user-control to parent. C# / WPF
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM