Reputation: 39
I am new to windows 8 app development using xaml and c#. I created a new image using.
Image img = new Image();
I successfully added the image to the canvas, but i want to add an eventhandler pointerpressed to the img. How do i do it?
Upvotes: 0
Views: 129
Reputation: 501
You have your Image instance in code
Image img = new Image();
And I'm presuming you've added it to your Canvas also in code, so the logical place to hook your event in code
Image img = new Image();
img.PointerPressed += Image_PointerPressed;
Where you have defined the Image_PointerPressed elsewhere in that same class
private void Image_PointerPressed(object sender, PointerRoutedEventArgs e)
{
// do what you want here...
}
Upvotes: 1