Question

What would be the equivalent for Mouse.GetPostion(null) which is in WPF.

I can get the position of pointer from the pointer event args. but how do i get the position without any event. like "Mouse.GetPostion(null)" in WPF. where mouse is a static class. Any idea?

Était-ce utile?

La solution

There is a PointerPoint.Position property - PointerPoint is a general input abstraction that also inludes touch and stylus input so you have to get a focus on mouse input first - this can be done with a static

 PointerPoint PointerPoint.GetCurrentPoint(uint pointerId)

method where pointerId is a system generated number identifying the input device. I don't know if there is any other way but you can get the mouse PointerId through

PointerRoutedEventArgs.Pointer.PointerId

if you handle some mouse Pointer event like PointerPressed or PointerReleased first.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top