How do I get the co-ordinates of a mouse click on a transformed WPF control?
Posted
by BlackWasp
on Stack Overflow
See other posts from Stack Overflow
or by BlackWasp
Published on 2010-05-08T22:09:01Z
Indexed on
2010/05/08
23:28 UTC
Read the original article
Hit count: 283
wpf
I'm playing with a simple WPF application. One part of it includes a grid containing several controls. The grid is rotated using a LayoutTransform and a RotateTransform. I need to get the co-ordinates of a mouse-click relative to the top-left of the grid, taking the rotation into account.
To be clear, let's say I have a single drawing surface within the grid and no transform had been applied. I then click at location X = 20, Y = 10 and put a dot on the drawing surface at that point. If the grid is now rotated by 30 degrees and I click on the dot (which is also moved by the rotation), the click position should still be X = 20, Y = 10.
© Stack Overflow or respective owner