您可以将Path 控件与包含ArcSegment 的适当PathGeometry 一起使用。
在下面的示例中,(100,100) 是圆弧的中心点,(50,50) 和 (150,50) 是圆弧的起点和终点。请注意,圆弧是一段椭圆,其中 ArcSegment 的 Size 属性指定椭圆半径。这里是一个半径为50*sqrt(2)的圆。
<Path Stroke="Black">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="100,100" IsClosed="True">
<LineSegment Point="50,50"/>
<ArcSegment Point="150,50" Size="70.7,70.7" SweepDirection="Clockwise"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
或更短:
<Path Stroke="Black" Data="M100,100 L50,50 A70.7,70.7 0 0 1 150,50Z" />
假设你的视图模型有四个描述弧形图形的属性
public Point Center { get; private set; } = new Point(100, 100);
public Point Start { get; private set; } = new Point(50, 50);
public Point End { get; private set; } = new Point(150, 50);
public Size Size { get; private set; } = new Size(70.7, 70.7);
您可以使用这样的绑定编写 XAML:
<PathFigure StartPoint="{Binding Center}" IsClosed="True">
<LineSegment Point="{Binding Start}"/>
<ArcSegment Point="{Binding End}" Size="{Binding Size}" SweepDirection="Clockwise"/>
</PathFigure>
你当然也可以在后面的代码中创建这样的几何图形。