ind*_*moz 41
您可以使用适用于Windows Phone 7GestureService的Silverlight Control Toolkit.在你的UI元素中,添加以下代码片段(在WP7项目中引用工具包的DLL之后) -
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Flick="OnFlick"/>
</toolkit:GestureService.GestureListener>
Run Code Online (Sandbox Code Playgroud)
在代码隐藏文件中实现处理程序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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
希望这有帮助,indyfromoz
如果您不想使用silverlight工具包,可以使用XNA框架.
http://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
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19047 次 |
| 最近记录: |