Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

wpf

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

like image 880
Code0987 Avatar asked Nov 04 '10 09:11

Code0987


1 Answers

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

like image 71
Zain Shaikh Avatar answered Sep 16 '22 14:09

Zain Shaikh