【发布时间】:2010-11-04 09:23:02
【问题描述】:
如何在 WPF 运行时获取控件的 XY 坐标?
【问题讨论】:
-
这是一个重复的问题
标签: wpf
如何在 WPF 运行时获取控件的 XY 坐标?
【问题讨论】:
标签: wpf
为此,有 TransformToAncestor 方法:
Point relativePoint = myVisual.TransformToAncestor(rootVisual)
.Transform(new Point(0, 0));
myVisual 是您想要获得其位置的元素,rootVisual 是 Application.Current.MainWindow 或任何您想要的相对位置。
参考链接:
Get Absolute Position of element within the window in wpf
【讨论】: