views:

99

answers:

1

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

+2  A: 

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
The field, constructor or member 'TranslatePoint' is not defined
akaphenom
It is defined in WPF. In Silverlight, you must use `element.TransformToVisual(root).Transform(new Point(0.0, 0.0))`.
Julien Lebosquain
Bingo! Do you know why that is?
akaphenom
I suppose that methods that are just shortcuts to other methods are not present in Silverlight to avoid bloating the assembly.
Julien Lebosquain