Reputation: 9138
I want to do the following XAML code in code behind and not sure how to add the GestureService and GestureListner onto the Image.
Xaml code:
<Image Grid.Row="1" x:Name="img" VerticalAlignment="Center" HorizontalAlignment="Center" Width="200">
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener/>
</toolkit:GestureService.GestureListener>
</Image>
Code behind equivalent:
Image image = new Image();
//how do I add GestureService and GestureListner?
ContentPanel.Children.Add(image);
Upvotes: 2
Views: 579
Reputation: 1610
Do this:
GestureService.GetGestureListener(image);
Normal approach would be doing it this way:
GestureService.SetGestureListener(image, new GestureListener());
But GetstureService developers have marked SetGestureListener method as obsolete: "Do not add handlers using this method. Instead, use GetGestureListener, which will create a new instance if one is not already set, to add your handlers to an element."
Upvotes: 1