简体   繁体   English

在Windows Phone 8.1中向左或向右滑动

[英]swipe left or right in windows phone 8.1

I am looking to understand gesture or horizontal swipe event in windows phone 8.1. 我希望了解Windows Phone 8.1中的手势或水平滑动事件。 I have below code which works fine but don't how to understand the status of swipe. 我有下面的代码工作正常,但不知道如何理解滑动的状态。 Whether it is right swipe or left swipe. 无论是向右滑动还是向左滑动。 So my question is How to identify swipe right and left? 所以我的问题是如何识别左右滑动?

void MainPage_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            var ps = e.GetIntermediatePoints(null);
            if (ps != null && ps.Count > 0)
            {
                gr.ProcessUpEvent(ps[0]);
                e.Handled = true;
                gr.CompleteGesture();
            }
        }
        void gr_CrossSliding(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.CrossSlidingEventArgs args)
        {
            //How to know you swipe left and right

        }
        void MainPage_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            gr.ProcessMoveEvents(e.GetIntermediatePoints(null));
            e.Handled = true;
        }
        void MainPage_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            var ps = e.GetIntermediatePoints(null);
            if (ps != null && ps.Count > 0)
            {
                gr.ProcessDownEvent(ps[0]);
                e.Handled = true;
            }
        }

And my constructor 还有我的构造函数

Windows.UI.Input.CrossSlideThresholds cst = new Windows.UI.Input.CrossSlideThresholds();
cst.SelectionStart = 2;
cst.SpeedBumpStart = 3;
cst.SpeedBumpEnd = 4;
cst.RearrangeStart = 5;
gr.CrossSlideHorizontally = true;
gr.CrossSlideThresholds = cst;
gr.CrossSliding += gr_CrossSliding;

gr.GestureSettings = GestureSettings.CrossSlide;

One idea is to remember where was the first point pressed and then, upon release, check relesed position and compare with the rememered one. 一个想法是记住按下第一个点的位置,然后在释放时检查相关位置并与重新记录的位置进行比较。 This should allow to idetify in which direction user has moved his finger. 这应该允许用户理解用户移动手指的方向。

Also if it would be possible, you can also think of using Velocities when using manipulation events - example at this post . 如果可能的话,你也可以考虑在使用操作事件时使用Velocities - 例如在这篇文章中

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM