33

How to get XY coordinates of a control at runtime in WPF ?

1
  • 2
    this is a duplicated question Nov 4, 2010 at 9:27

1 Answer 1

85

For that, there is the TransformToAncestor method:

Point relativePoint = myVisual.TransformToAncestor(rootVisual)
                          .Transform(new Point(0, 0));

Where myVisual is the element you want to get the position of, and rootVisual is Application.Current.MainWindow or whatever you want the position relative to.

reference link:
Get Absolute Position of element within the window in wpf

Not the answer you're looking for? Browse other questions tagged or ask your own question.