我希望了解Windows Phone 8.1中的手势或水平滑动事件。我有下面的代码工作正常,但不知道如何理解滑动的状态。无论是向右滑动还是向左滑动。所以我的问题是如何识别左右滑动?
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;
}
}
我的构造函数
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;
答案 0 :(得分:0)
一个想法是记住按下第一个点的位置,然后在释放后检查相关位置并与重新记录的位置进行比较。这应该可以让用户理解用户移动手指的方向。
此外,如果有可能,您还可以考虑在使用操作事件时使用 Velocities - example at this post。