GestureService OnFlick [英] GestureService OnFlick

查看:56
本文介绍了GestureService OnFlick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在代码隐藏(即不在XAML中)中添加GestureService和Flick事件的处理程序?

How can I add the GestureService and a handler for the Flick event in code-behind (i.e. not in XAML)?

推荐答案

首先,请确保您已经添加了对用于Windows Phone 7的Silverlight工具包(特别是Microsoft)的引用。 Phone.Controls.Toolkit.dll程序集。然后确保您具有Microsoft.Phone.Controls命名空间的XML命名空间引用:

Firstly, make sure you've added a reference to the Silverlight Toolkit for Windows Phone 7, specifically the Microsoft.Phone.Controls.Toolkit.dll assembly. Then make sure you have an XML namespace reference for the Microsoft.Phone.Controls namespace:

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"

然后,添加 GestureService.GestureListener 到要在其上处理手势的控件:

Then, add the GestureService.GestureListener to the control you want to handle gestures on:

<TextBlock x:Name="test" Text="Test">
    <toolkit:GestureService.GestureListener>
        <toolkit:GestureListener Flick="TextBlock_Flick" />
    </toolkit:GestureService.GestureListener>
</TextBlock>

然后,您只需要在事件处理程序中实现逻辑即可。

Then you just need to implement your logic in the event handler.

更新:以上方法用于在XAML中使用 GestureService ;要在代码后面使用 GestureService ,请使用 GetGestureListener 方法:

Update: The above approach is for using the GestureService in XAML; to use the GestureService in code-behind you use the GetGestureListener method:

var listener = GestureService.GetGestureListener(this.test);
listener.Flick += this.TextBlock_Flick;

这篇关于GestureService OnFlick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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