从左到右,从右到左检测元素上的轻弹

时间:2014-01-28 15:14:21

标签: c# xaml windows-phone-8 windows-phone

如何在Windows Phone 8项目上的文本块上检测到轻弹,当它从左到右进行一件事,从右到左做另一件事? 我尝试在我的元素上使用MouseLeave =“Titulo_MouseLeave”,但它没有完全正常工作

1 个答案:

答案 0 :(得分:0)

aloisdg建议你可以使用Silverlight Toolkit。或者您可以将XNA用于此目的:

public MainPage()
{
   InitializeComponent();

   TouchPanel.EnabledGestures = GestureType.Flick;
   myTextBlock.ManipulationCompleted += myTextBlock_ManipulationCompleted;
}

private void myTextBlock_ManipulationCompleted(object sender, System.Windows.Input.ManipulationCompletedEventArgs e)
{
   if (TouchPanel.IsGestureAvailable)
   {
      GestureSample gesture = TouchPanel.ReadGesture();
      switch (gesture.GestureType)
      {
        case GestureType.Flick:
            if (e.FinalVelocities.LinearVelocity.X < 0)
                        // do for one side
            if (e.FinalVelocities.LinearVelocity.X > 0)
                        // do for second side
            break;
        default:
            break;
      }
  }
}