【发布时间】:2012-09-26 13:32:54
【问题描述】:
我想找到UIElement 的Left,Top,Right,Bottom。我试过但没有结果。
这里有人知道如何获得这些吗?
实际上,我正在 WPF 中创建一个自定义面板。
我不想从 Canvas 继承。
Size elemSize = this.ElementBeingDragged.DesiredSize;
// Get the element's offsets from the four sides of the Panel.
Vector v= VisualTreeHelper.GetOffset(this.ElementBeingDragged);
double left = v.X;
double right = v.X + elemSize.Width;
double top = v.Y;
double bottom = v.Y+elemSize.Height;
【问题讨论】:
-
你试过 TranslatePoint 或 TransformToAncestor 吗?