Draws a polygon, which is a connected series of lines that form a closed shape.
To create an object using scripting, see CreateFromXAML.
Canvas.Left, Canvas.Top, Canvas.ZIndex, Clip, Cursor, Fill, FillRule, Height, Name, Opacity, OpacityMask, Points, RenderTransform, RenderTransformOrigin, Resources, Stretch, Stroke, StrokeDashArray, StrokeDashCap, StrokeDashOffset, StrokeEndLineCap, StrokeLineJoin, StrokeMiterLimit, StrokeStartLineCap, StrokeThickness, Tag, Triggers, Width
The simplest true polygon is a triangle, in which case the Points property will have three entries. A Polygon with two points in Points will still render so long as it has a nonzero StrokeThickness value and a nonnull Stroke value, but that same result could be accomplished with Line. A Polygon with only one point will not render.
The following example shows how to use a Polygon to create a triangle.
<Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <!-- 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 300,200" Stroke="Purple" StrokeThickness="2"> <Polygon.Fill> <SolidColorBrush Color="Blue" Opacity="0.4"/> </Polygon.Fill> </Polygon> </Canvas>
The following illustration shows the rendered shape.