在c#中,是否有可能找到PathFigureCollection对象的边界矩形呢?
(我知道可以使用FrameworkElement获取它,但那不是我想要的)
PathFigureCollection
包含在PathGeometry
对象中,然后你就可以通过Bounds
属性访问边界矩形。
示例
var geometry = new PathGeometry {
Figures = new PathFigureCollection()
};
var boundingRect = geometry.Bounds;
PathFigureCollection
分配给Figures
属性,而不是创建一个新的。还有一个构造函数接受PathFigureCollection
参数,所以你可以简单地编写var bounds = new PathGeometry(figures).Bounds;
。 - Clemens