关键代码:
protected override Geometry DefiningGeometry {
get {
Geometry result = new RectangleGeometry(new Rect(0, 0, base.Width, base.Height), RadiusX, RadiusY);
double halfWidth = base.Width / 2;
double halfHeight = base.Height / 2;
if (!RoundTopLeft)
result = new CombinedGeometry(GeometryCombineMode.Union, result, new RectangleGeometry(new Rect(0, 0, halfWidth, halfHeight)));
if (!RoundTopRight)
result = new CombinedGeometry(GeometryCombineMode.Union, result, new RectangleGeometry(new Rect(halfWidth, 0, halfWidth, halfHeight)));
if (!RoundBottomLeft)
result = new CombinedGeometry(GeometryCombineMode.Union, result, new RectangleGeometry(new Rect(0, halfHeight, halfWidth, halfHeight)));
if (!RoundBottomRight)
result = new CombinedGeometry(GeometryCombineMode.Union, result, new RectangleGeometry(new Rect(halfWidth, halfHeight, halfWidth, halfHeight)));
return result;
}
}