如何在 Windows Phone 7 中滑动 [英] how to get swipe in windows phone 7

查看:30
本文介绍了如何在 Windows Phone 7 中滑动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Windows Phone 7 中滑动图像.我从哪里开始?

I want to swipe images in windows phone 7. Where do I begin from?

推荐答案

您可以使用 适用于 Windows Phone 7 的 Silverlight 控制工具包.在您的 UI 元素中,添加以下代码段(在您的 WP7 项目中引用工具包的 DLL 之后) -

You can use the GestureService in the Silverlight Control Toolkit for Windows Phone 7. In your UI element, add the following piece of code (after you have referenced the toolkit's DLL in your WP7 project) -

<toolkit:GestureService.GestureListener>
    <toolkit:GestureListener Flick="OnFlick"/>
</toolkit:GestureService.GestureListener>  

在代码隐藏文件中实现处理程序 OnFlick,就像这样 -

Implement the handler OnFlick in the code-behind file, like so -

private void OnFlick(object sender, FlickGestureEventArgs e)
{
   var vm = DataContext as SelectedCatalogViewModel;
   if (vm != null)
   {
      // User flicked towards left
      if (e.HorizontalVelocity < 0)
      {
         // Load the next image 
         LoadNextPage(null);
      }

      // User flicked towards right
      if (e.HorizontalVelocity > 0)
      {
         // Load the previous image
         LoadPreviousPage();
      }
   }
}

希望这有帮助,indyfromoz

Hope this helps, indyfromoz

这篇关于如何在 Windows Phone 7 中滑动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆