I want to get mouse position relative to screen coordinates. I am using the following code to do that.
window.PointToScreen(Mouse.GetPosition(window));
It is working as expected. But my MouseMove event not firing outside the MainWindow. That is if I move my mouse over desktop with my window restored.
Any ideas appreciated.
I needed to be able to capture mouse position outside of the WPF window regardless of any mouse button pressed. I ended up using Interop to call a WINAPI GetCursorPos combined with a thread instead of an event for the window.
Works great!
Use the CaptureMouse() method.
For your example above, you could add:
in your code-behind inside the MouseDown event handler.
You then need to call:
in your code-behind inside the MouseUp event handler.