Share via


如何:建立橢圓弧形

這個範例示範如何繪製橢圓形弧線。若要建立橢圓形弧線,請使用 PathGeometryPathFigureArcSegment 類別。

範例

在下列範例中,橢圓形弧線是從 (10,100) 繪製到 (200,100)。 弧線具有 Size 100 x 50 個裝置獨立圖元、 RotationAngle 45 度 IsLargeArc 、設定 trueSweepDirectionCounterclockwise

在 Extensible Application Markup Language (XAML)中,您可以使用屬性語法來描述路徑。

<Path Stroke="Black" StrokeThickness="1"  
  Data="M 10,100 A 100,50 45 1 0 200,100" />

(請注意,這個屬性語法實際上會建立 、 StreamGeometry 較輕量版本的 PathGeometry 。如需詳細資訊,請參閱 路徑標記語法 頁面。

在 XAML 中,您也可以使用物件標記明確繪製橢圓形弧線。 下列專案相當於上述 XAML 標記。

<Path Stroke="Black" StrokeThickness="1">
  <Path.Data>
    <PathGeometry>
      <PathGeometry.Figures>
        <PathFigureCollection>
          <PathFigure StartPoint="10,100">
            <PathFigure.Segments>
              <PathSegmentCollection>
                <ArcSegment Size="100,50" RotationAngle="45" IsLargeArc="True" SweepDirection="CounterClockwise" Point="200,100" />
              </PathSegmentCollection>
            </PathFigure.Segments>
          </PathFigure>
        </PathFigureCollection>
      </PathGeometry.Figures>
    </PathGeometry>
  </Path.Data>
</Path>

這個範例是某完整範例的一部分。 如需完整的範例,請參閱 幾何範例

另請參閱