How to get XY coordinates of a control at runtime in WPF ?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With