开发者

get the coordinates of a FrameworkElement bounding rectangle

开发者 https://www.devze.com 2022-12-31 14:09 出处:网络
How does one get the upper left coordinates of a framewo开发者_如何学Gork elements bounding rectangle?

How does one get the upper left coordinates of a framewo开发者_如何学Gork 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消