Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get the coordinates of a FrameworkElement bounding rectangle

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

like image 282
akaphenom Avatar asked May 23 '10 17:05

akaphenom


1 Answers

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.

like image 179
Julien Lebosquain Avatar answered Oct 20 '22 14:10

Julien Lebosquain