Unlike the other techniques seen in this chapter, Toolkit gestures are provided as a separate assembly, as part of the Windows Phone Toolkit package. To learn how to obtain the Toolkit, see Chapter 9.
The two main classes for working with Toolkit gestures are the GestureService
and GestureListener
classes. GestureService
is used only to attach a GestureListener
to a UIElement
. Like manipulation events, Toolkit gestures are used in conjunction with a UIElement
. Once attached, the GestureListener
monitors the element for gestures that the element can support, such as tap, hold, pinch, and flick.
GestureListener
allows you to specify handlers for each gesture type. The following example shows a Border
control with subscriptions to these events via the attached GestureListener
:
<Border Background="{StaticResource PhoneAccentBrush}">
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener
GestureBegin="HandleGestureBegin"
GestureCompleted="HandleGestureCompleted"
Tap="HandleTap"
DoubleTap="HandleDoubleTap"
Hold="HandleHold"
DragStarted="HandleDragStarted"
DragDelta="HandleDragDelta"
DragCompleted="HandleDragCompleted"
Flick="HandleFlick"
PinchStarted="HandlePinchStarted"
PinchDelta="HandlePinchDelta"
PinchCompleted="HandlePinchCompleted">
</toolkit:GestureListener>
</toolkit:GestureService.GestureListener>
</Border>
The GestureListener
class is designed for Silverlight’s event-driven model. The class effectively wraps the low-level Silverlight touch mechanism to perform automatic conversion of the Touch.FrameReported
events into unique events for each gesture type.
3.145.179.35