I can find only MouseDown Event and MouseUp Event on a image in WPF.
This causes some problem if I do MouseDown on some Image, Move the mouse and MouseUp event happens on some other image.
Is there any other event that I can use to solve this problem. like MouseClick Event for Button element.
I can find only MouseDown Event and MouseUp Event on a image in WPF.
Share
If you really must use an image then there’s a couple of things you can do to check for a “click”.
Check the time between the two events. If it’s less than your threshold, then treat the mouse up as a click. You’ll need to store the time of the mouse down event.
Check that the
senderof both events is the same. Again you’ll need to store thesenderof the mouse down event.You might also want to check that it’s the left button that’s been pressed and released.
Combining the two:
There’s actually a third thing you can do: Check the mouse position.
save the position:
then check it in the
MouseUpevent, again with a tolerance value.