共用方式為


HOW TO:使用 PathGeometry 建立圖案

更新:2007 年 11 月

本範例顯示如何使用 PathGeometry 類別建立圖案。PathGeometry 物件是由一個或多個 PathFigure 物件所組成,其中每個 PathFigure 各代表一個不同的「圖形」或圖案。每個 PathFigure 本身都是由一個或多個 PathSegment 物件所組成,其中每個物件各代表圖形或圖案的某個連接部分。區段類型包括 LineSegmentArcSegmentBezierSegment

範例

下列範例使用 PathGeometry 建立三角形。PathGeometry 會透過 Path 項目顯示。

<Path Stroke="Black" StrokeThickness="1">
  <Path.Data>
    <PathGeometry>
      <PathGeometry.Figures>
        <PathFigureCollection>
          <PathFigure IsClosed="True" StartPoint="10,100">
            <PathFigure.Segments>
              <PathSegmentCollection>
                <LineSegment Point="100,100" />
                <LineSegment Point="100,50" />
              </PathSegmentCollection>
            </PathFigure.Segments>
          </PathFigure>
        </PathFigureCollection>
      </PathGeometry.Figures>
    </PathGeometry>
  </Path.Data>
</Path>

下圖顯示在上述範例中建立的圖案。

使用 PathGeometry 建立的三角形

PathGeometry

上述範例顯示了如何建立三角形這類比較簡單的圖案。PathGeometry 也可以用來建立更複雜的圖案,包括弧線和曲線。如需相關範例,請參閱 HOW TO:建立橢圓弧形HOW TO:建立三次方貝茲曲線HOW TO:建立二次方貝茲曲線

本範例是完整範例的一部分;如需完整範例,請參閱幾何範例

請參閱

工作

幾何範例

概念

幾何概觀

參考

Path

GeometryDrawing