Reputation: 91
I don’t understand how to use some features from Windows Phone Toolkit in cs code in Silverlight (more precise, I don’t understand how to use GestureListener). I saw many examples of using GestureListener in xaml like this
<Image Source="something.jpg">
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Tap="image_Tap" Hold="image_Hold" />
</toolkit:GestureService.GestureListener>
</Image>
And this works fine, but I create images dynamically and want dynamically add gesture handlers in cs code. Can someone give an example how to do the same thing only in cs code?
Upvotes: 9
Views: 6214
Reputation: 121
SetGestureListener was deprecated , that`s right, instead you can use GetGestureListener like this
var gl = GestureService.GetGestureListener(img);
gl.DoubleTap += new EventHandler<GestureEventArgs>(GestureListenerDoubleTap);
Upvotes: 12
Reputation: 69252
Attached properties typically have a SetPropertyName and GetPropertyName method pair that correspond to the above XAML. I don't have experience with the Windows Phone 7 specifically, but the above would probably be done as:
GestureService.SetGestureListener(myImage, new GestureListener {
Tap = "image_Tap",
Hold = "image_Hold"
});
If those Tap
and Hold
properties are images, you will need to load some BitmapImage objects programmatically instead of strings.
Upvotes: 1