Microsoft Dot Net Master

Microsoft Dot Net Master
Microsoft Dot Net Master

Thursday, July 19, 2012

Mouse Handling in WPF

How to get the Absolute Position of the Mouse on the Screen

You can call Mouse.GetPosition(this) on any WPF element. This function returns the relative offset of the mouse to the upper left corner of your control.
To get the absolute screen cordinates, call the PointToScreen() function.
 
  Point absoluteScreenPos = PointToScreen( Mouse.GetPosition( new Point(), this ));

No comments:

Post a Comment