-api-id | -api-type |
---|---|
T:Windows.UI.Xaml.Shapes.Polygon |
winrt class |
Draws a polygon, which is a connected series of lines that form a closed shape.
<Polygon .../>
The Polygon object is similar to the Polyline object, except that Polygon must be a closed shape.
You define the shape by adding vertices to the Points collection. For example, two points could form a line, three points could form a triangle, and four points could form a quadrilateral.
The FillRule property specifies how the interior area of the shape is determined. See the FillRule enumeration for more info.
You can set the Fill property to give the shape a background fill, like a solid color, gradient, or image. You can set the Stroke and other related stroke properties to specify the look of the shape's outline.
This example shows how to use a Polygon to create a triangle.
<Canvas>
<!- - This polygon shape uses pre-defined color values for its Stroke and
Fill properties.
The SolidColorBrush's Opacity property affects the fill color in
this case by making it slightly transparent (opacity of 0.4) so
that it blends with any underlying color. - ->
<Polygon
Points="300,200 400,125 400,275"
Stroke="Purple"
StrokeThickness="2">
<Polygon.Fill>
<SolidColorBrush Color="Blue" Opacity="0.4"/>
</Polygon.Fill>
</Polygon>
</Canvas>