Thursday, November 21, 2013

Get Absolute Position of element within the window in wpf

You have to specify window you clicked in Mouse.GetPosition(IInputElement relativeTo) Following code works well for me
protected override void OnMouseDown(MouseButtonEventArgs e)
        Point p = e.GetPosition(this);
I suspect that you need to refer to the window not from it own class but from other point of the application. In this case Application.Current.MainWindow will help you.


No comments: