|
|
|
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 ));
Last modified: 2009-06-17 17:39:50
Copyright (c) by Christian Moser, 2011.
Comments on this article
Show all comments
|
Johhny Rubber | |
|
Commented on 11.August 2009 |
This is how you do it in WPF NOT JAVA, for gods sake.
|
|
|
|
David | |
|
Commented on 22.February 2010 |
Thank you very much ! it's so hard to find a good solution to do that !
|
|
|
|
Jeff | |
|
Commented on 14.September 2010 |
Johhny Rubber wrote " This is how you do it in WPF NOT JAVA, for gods sake."
This is a WPF tutorial and not Java, so why would you think otherwise?
|
|
|
|
balaji | |
|
Commented on 6.February 2011 |
It really works!
|
|
|
|
Paul | |
|
Commented on 15.February 2011 |
Jeff wrote "This is a WPF tutorial and not Java, so why would you think otherwise?"
Perhaps somebody was talking about Java, and Johnny was trying to correct them by telling them that this is a WPF tutorial.
|
|
|
|
Alisator | |
|
Commented on 1.April 2011 |
Java? wtf? That´t not possible, for gods sake. Think...
|
|
|
|
Brandon | |
|
Commented on 1.May 2011 |
Nice tut.
|
|
|
|
xl | |
|
Commented on 27.September 2011 |
hi, is there a way to set the position of the mouse?
|
|
|
|
|
|