Export (0) Print
Expand All

Polygon.Points Property

Gets or sets a collection that contains the vertex points of the polygon.

Namespace:  System.Windows.Shapes
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public PointCollection Points { get; set; }
<object>
  <object.Points>
    <PointCollection .../>
  </object.Points>
</object>
<object Points="PointCollection" .../>

Property Value

Type: System.Windows.Media.PointCollection
A collection of Point structures that describe the vertex points of the polygon. The default is a null reference (Nothing in Visual Basic).

Identifier field

PointsProperty

Metadata properties set to true

AffectsRender, AffectsMeasure

In Extensible Application Markup Language (XAML), use a space-delimited list of comma-separated x-coordinate and y-coordinate pairs to set this attribute. Use simple notation, that is, x1,y1 x2,y2 ... xn,yn.

The following example shows how to create a Polygon element and set the Points property by using code.



//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);


More Code

How to: Draw a Closed Shape by Using the Polygon ElementThis example shows how to draw a closed shape by using the Polygon element. To draw a closed shape, create a Polygon element and use its Points property to specify the vertices of a shape. A line is automatically drawn that connects the first and last points. Finally, specify a Fill, a Stroke, or both.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft