WPF : How to get mouse position in Window_Loaded(object sender, RoutedEventArgs e) event
Asked
Active
Viewed 2,294 times
1 Answers
0
Have you tried using PointToScreen(Mouse.GetPosition(this))
?
(in the System.Windows.Input
namespace)

Filipe Miguel
- 519
- 1
- 6
- 13
-
Yes,I have tried GetPosition(Element). It's have to use input element as parameter,isn't it?. I want to get mouse coordinate after click a button on wpf application and show a dialog over the mouse position – Prince OfThief Nov 19 '10 at 16:03
-
After testing it a bit more it seems it doesn't really matter which element is passed as the parameter. If your using it on a button_click handler you can call it as `PointToScreen(Mouse.GetPosition(sender as Button))`. The results are absolute, no relative to the control. – Filipe Miguel Nov 19 '10 at 16:31