Getting the true visual bounding box of a WPF element?

前端 未结 3 1075
醉话见心
醉话见心 2020-12-18 05:53

For a simplified version of my problem, I would like to calculate the bounding box of a layout-transformed (possibly even render-transformed) shape, so that I can always fit

3条回答
  •  囚心锁ツ
    2020-12-18 05:58

    private Rect GetRectOfObject(FrameworkElement _element)
    {
        Rect rectangleBounds = new Rect();
        rectangleBounds = _element.RenderTransform.TransformBounds(new Rect(0, 0, _element.Width, _element.Height));
        return rectangleBounds;
    }
    

    Maybe this will help out.

提交回复
热议问题