A polygon is a series of connected lines which is a closed shape. A closed shape is a shape that has same start point and end point.
The Polygon object represents a polygon shape and draws a polygon for the given connected points. The Fill property fills the interior of an ellipse. The Stroke property sets the color and StrokeThickness represents the width of the outer line of an ellipse. The Points property of the Polygon represents a collection of Point that defines the points in a polygon. The FillRule property represents how the interior of the polygon is determined.
Creating a Polygon
The Polygon element in XAML creates a polygon shape. The following code snippet creates a polygon by setting its Points property to the connected points in a polygon. The code also sets the black stroke of width 4 and fills it with yellow color.
The output looks like Figure 11.
Figure 11. A Polygon
The CreateAPolygon method listed in Listing 10 draws the same rectangle in Figure 11 dynamically.
Listing 10