我在我的wp7应用程序中使用了一个透视页面。PivotItems是通过编程添加的。我需要得到所有手势的事件。我怎样才能得到它们呢?
那么,如何知道轻拍手势的方向呢?滑动后如何获取当前物品的详细信息。
我试过这个:WP7: Questions regarding Touch Gestures。但无法添加
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Flick="GestureListener_Flick" />
</toolkit:GestureService.GestureListener>当我试图添加这段代码时,发生了一个错误。
如何获取手势事件?
发布于 2012-03-29 04:17:00
在XNA库中还有对检测触摸的额外支持。尝试将Microsoft.Xna.Framework.Input.Touch引用添加到项目中
包含以下using语句:
using Microsoft.Xna.Framework.Input.Touch;在构造函数中订阅所需的事件,如下所示:
TouchPanel.EnabledGestures = GestureType.Tap | GestureType.Flick;在您的控件上创建一个用于操作的事件,如下所示:
ManipulationCompleted="Object_ManipulationCompleted"您可以向该事件方法中添加代码,以跟踪已使用以下代码完成的事件类型:
private void Object_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
{
while (TouchPanel.IsGestureAvailable)
{
GestureSample gesture = TouchPanel.ReadGesture();
if (gesture.GestureType == GestureType.Tap)
{
//Do something
}
if (gesture.GestureType == GestureType.Flick)
{
//The delta contains the direction of the flick (negative/positive)
//gesture.Delta.Y;
//gesture.Delta.X;
}
}
}希望这能有所帮助
https://stackoverflow.com/questions/9701411
复制相似问题