Reputation: 27
I use windows phone 7, with silverlight. I have an image on my page and I want that when the user clicks on the image an event will raise. Moreover, If it is possible I would like to know on which point of the image the user clicked.
Upvotes: 0
Views: 905
Reputation: 913
The WP7 Silverlight Toolkit (http://silverlight.codeplex.com/) has GestureListeners where you can attach a Tap Gesture to your image and catch the event.
<Image>
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener
Tap="OnTap"/>
</toolkit:GestureService.GestureListener>
</Image>
Upvotes: 1
Reputation: 1738
Try this you probebly have to consider the image location relative to coordinates.. the coordinates are probebly relative to the root element.
<Image MouseLeftButtonUp="image_MouseLeftButtonUp" x:Name="image" />
private void image_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
string x = e.GetPosition((UIElement)sender).X.ToString();
string y = e.GetPosition((UIElement)sender).y.ToString();
}
Upvotes: 4
Reputation: 4347
I've check all the events you can bind to an image tag, there should be one called MouseLeftButtonDown
and MouseLeftButtonUp
see if that gets you on the right track.
Upvotes: 0