6

How does one get the upper left coordinates of a framework elements bounding rectangle?

    let fe : FrameworkElement = ea.Item.Content 
    let p = fe.TranslatePoint(new Point(0.0, 0.0), null)

The preceding code is giving me: The field, constructor or member 'TranslatePoint' is not defined. I am confused as MSDN Shows this as a memeber of FrameworkElement inherited from UIElement:

http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement_members(v=VS.100).aspx

akaphenom
  • 6,728
  • 10
  • 59
  • 109

1 Answers1

15

Use element.TranslatePoint(new Point(0.0, 0.0), null) to get the upper left coordinates of element relative to the logical root element. If you want it relative to another element, specify it at the second parameter instead of null. You can then use ActualWidth and ActualHeight to compute the whole rectangle.

Julien Lebosquain
  • 40,639
  • 8
  • 105
  • 117