2
votes

I have a Canvas with two or more objects. Now, I put these objects in a new Canvas placed in the previous Canvas. Then, I rotate it.

Now, I want to know how to get the positions of the objects in the new Canvas, as though there were no new canvas.

Image1

1

1 Answers

0
votes

You can use the following extension method to get the location of one UIElement with respect to another:

  public static class ExtensionMethods
  {
    public static Point GetRelativePosition(this UIElement element, UIElement other)
    {
      return element.TransformToVisual(other)
                    .Transform(new Point(0, 0));
    }
  }