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.
假设我有这个 XAML 代码:
<StackPanel Name="pan"> <Button Name="but1" Content="Helllo" /> <Button Name="but2" Content="all" /> <Button Name="but3" Content="World" /> </StackPanel>
我后面的代码我想找出 inside 的坐标是but2什么pan。我该怎么做 ?
but2
pan
像这样的东西:
private Point GetPositionOfBut2() { var positionTransform = but2.TransformToAncestor(pan); var position = positionTransform.Transform(new Point(0, 0)); return position; }