【问题标题】:How to get XY coordinates of a control at runtime in WPF? [duplicate]如何在 WPF 运行时获取控件的 XY 坐标? [复制]
【发布时间】:2010-11-04 09:23:02
【问题描述】:

如何在 WPF 运行时获取控件的 XY 坐标?

【问题讨论】:

  • 这是一个重复的问题

标签: wpf


【解决方案1】:

为此,有 TransformToAncestor 方法:

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

myVisual 是您想要获得其位置的元素,rootVisualApplication.Current.MainWindow 或任何您想要的相对位置。

参考链接:
Get Absolute Position of element within the window in wpf

【讨论】:

    猜你喜欢
    • 2013-03-09
    • 1970-01-01
    • 1970-01-01
    • 2020-11-28
    • 2011-03-05
    • 2016-08-30
    • 2019-08-22
    • 2010-10-24
    • 1970-01-01
    相关资源
    最近更新 更多