Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道如何遍历 WPF 中的所有元素Grid,然后访问所有这些元素的绝对定位值 (X, Y) UIElements。
Grid
UIElements
foreach (UIElement child in grid.Children) { MatrixTransform t = (MatrixTransform)child.TransformToAncestor(grid); Point childLocation = new Point(t.Value.OffsetX, t.Value.OffsetY); }
将为您提供所有直接子级相对于Grid.