共用方式為


Polygon.Points 屬性

定義

取得或設定包含多邊形各頂點的集合。

public:
 property System::Windows::Media::PointCollection ^ Points { System::Windows::Media::PointCollection ^ get(); void set(System::Windows::Media::PointCollection ^ value); };
public System.Windows.Media.PointCollection Points { get; set; }
member this.Points : System.Windows.Media.PointCollection with get, set
Public Property Points As PointCollection

屬性值

描述多邊形頂點的 Point 結構集合。 預設為 null 參考 (在 Visual Basic 中為 Nothing)。

範例

下列範例示範如何使用程式碼建立 Polygon 專案並設定 Points 屬性。


//Add the Polygon Element
myPolygon = gcnew Polygon();
myPolygon->Stroke = Brushes::Black;
myPolygon->Fill = Brushes::LightSeaGreen;
myPolygon->StrokeThickness = 2;
myPolygon->HorizontalAlignment = HorizontalAlignment::Left;
myPolygon->VerticalAlignment = VerticalAlignment::Center;
Point Point1 = Point(1, 50);
Point Point2 = Point(10, 80);
Point Point3 = Point(50, 50);
PointCollection^ myPointCollection = gcnew PointCollection();
myPointCollection->Add(Point1);
myPointCollection->Add(Point2);
myPointCollection->Add(Point3);
myPolygon->Points = myPointCollection;
myGrid->Children->Add(myPolygon);

//Add the Polygon Element
myPolygon = new Polygon();
myPolygon.Stroke = System.Windows.Media.Brushes.Black;
myPolygon.Fill = System.Windows.Media.Brushes.LightSeaGreen;
myPolygon.StrokeThickness = 2;
myPolygon.HorizontalAlignment = HorizontalAlignment.Left;
myPolygon.VerticalAlignment = VerticalAlignment.Center;
System.Windows.Point Point1 = new System.Windows.Point(1, 50);
System.Windows.Point Point2 = new System.Windows.Point(10,80);
System.Windows.Point Point3 = new System.Windows.Point(50,50);
PointCollection myPointCollection = new PointCollection();
myPointCollection.Add(Point1);
myPointCollection.Add(Point2);
myPointCollection.Add(Point3);
myPolygon.Points = myPointCollection;
myGrid.Children.Add(myPolygon);

' Add a Polygon Element
Dim myPolygon As New Polygon()
myPolygon.Stroke = Brushes.Black
myPolygon.Fill = Brushes.LightSeaGreen
myPolygon.StrokeThickness = 2
myPolygon.HorizontalAlignment = HorizontalAlignment.Left
myPolygon.VerticalAlignment = VerticalAlignment.Center
Dim Point1 As New System.Windows.Point(1, 50)
Dim Point2 As New System.Windows.Point(10, 80)
Dim Point3 As New System.Windows.Point(50, 50)
Dim myPointCollection As New PointCollection()
myPointCollection.Add(Point1)
myPointCollection.Add(Point2)
myPointCollection.Add(Point3)
myPolygon.Points = myPointCollection
myGrid.Children.Add(myPolygon)

備註

在 Extensible Application Markup Language (XAML) 中,使用逗號分隔 x 座標和 y 座標組的空間分隔清單來設定此屬性。 使用簡單標記法,也就是 x1,y1 x2,y2 ... xn,yn

相依性屬性資訊

識別碼欄位 PointsProperty
設定為 的中繼資料屬性 true AffectsRender, AffectsMeasure

適用於

另請參閱