Jack B
Jack B

Reputation: 149

c# wpf - Can I get the coordinates to a pixel clicked in an image control

I have an Image control running in my MainWindow.xaml, I was wondering if I can get the X and Y coordinates to the pixel clicked from the RoutedEventArgs on the MouseUp event for the control? I don't need the color or anything at that pixel, I would just like to know where that pixel was. Thank you for the help.

Upvotes: 0

Views: 1795

Answers (1)

King King
King King

Reputation: 63317

You can try handling the MouseLeftButtonUp event:

private void image1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e){
    Point pos = e.GetPosition(image1);
}

Upvotes: 1

Related Questions