I am creating a Path
dynamically and I've noticed that the bounding Rect
of the shape is far larger than the path itself, like in the picture bellow.
Is it possible to alter those bounds? Unfortunatelly the PathGeometry.Bounds
property is read-only.
ps: If it helps, I am interested in narrowing the bounds so I can set RenderTransformOrigin
of the path to new Point(0.5,0.5)
to Rotate (RotateTransform
) that path around itself.
I am defining 4 points and then I create three LineSegment
s and the ArcSegment
. I've created a Circle
struct to use as a guide to calculate those points.
private PathFigure CreateFigure()
{
var lineAB = new LineSegment(pointB, true);
var arcBC = new ArcSegment(pointC, new Size(_outerCircle.Radius, _outerCircle.Radius), 0, false, SweepDirection.Clockwise, true);
var lineCD = new LineSegment(pointD, true);
return new PathFigure(pointA, new List<PathSegment> { lineAB, arcBC, lineCD }, true);
}
Since it's impossible to alter the bounds after they're defined, adding the Path
as a child to a Grid
or a Border
and setting Path.Stretch="Fill"
would force the bounds to be filled by the path during the layout pass.