我想在Windows Phone 7上滑动图片,从哪里开始?
我想在Windows Phone 7上滑动图片,从哪里开始?
你可以在Windows Phone 7的Silverlight控制工具包中使用GestureService
。在你的UI元素中,添加以下代码(在你已经将工具包的DLL引用到你的WP7项目后) -
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Flick="OnFlick"/>
</toolkit:GestureService.GestureListener>
在代码后台文件中实现OnFlick处理程序,如下所示 -
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
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
- swinefeasterhttp://www.nickharris.net/2010/11/using-touchpanel-for-gestures-in-windows-phone-7/
试试这个:
using Microsoft.Phone.Controls;
public partial class MyControl
{
public MyControl()
{
InitializeComponent();
var gl = GestureService.GetGestureListener(asd);
gl.Flick += new EventHandler<FlickGestureEventArgs>(GestureListener_Flick);
}
private void GestureListener_Flick(object sender, FlickGestureEventArgs e)
{
if (e.Direction == Orientation.Horizontal)
{
if (e.HorizontalVelocity < 0) // determine direction (Right > 0)
{
//Some Action
}
else
{
//Some Action
}
}
}
}