gpt4 book ai didi

c# - UIElement 相对于 Window 的位置

转载 作者:行者123 更新时间:2023-11-30 14:19:57 26 4
gpt4 key购买 nike

在 WPF 中,我想在我的代码中获取 TabControl 的角位置,以便在显示时相应地设置 ToolWindow 的位置。

如何获取给定 UIElement 的位置?

buildingInfoWindow = new BuildingInfoWindow(); // BuildingWindow : System.Windows.Window
buildingInfoWindow.Owner = this;

//buildingInfoWindow.Left = ?; // relative X coordinate of my TabControl
//buildingInfoWindow.Top = ?; // relative Y coordinate of my TabControl

最佳答案

Point pt = tabControl.TranslatePoint(new Point(0, 0), windowInstance);

关于c# - UIElement 相对于 Window 的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1854484/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com