如何获取PathFigureCollection边界矩形

3
在c#中,是否有可能找到PathFigureCollection对象的边界矩形呢? (我知道可以使用FrameworkElement获取它,但那不是我想要的)
1个回答

7
尝试将你的PathFigureCollection包含在PathGeometry对象中,然后你就可以通过Bounds属性访问边界矩形。 示例
var geometry = new PathGeometry {
    Figures = new PathFigureCollection()
};
var boundingRect = geometry.Bounds;

1
+1,但是你需要将现有的PathFigureCollection分配给Figures属性,而不是创建一个新的。还有一个构造函数接受PathFigureCollection参数,所以你可以简单地编写 var bounds = new PathGeometry(figures).Bounds; - Clemens

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接