Export (0) Print
Expand All
Run
Expand Minimize

Polygon

Silverlight

Draws a polygon, which is a connected series of lines that form a closed shape.

<Polygon   .../>

The simplest true polygon is a triangle, in which case the Points property will have three entries. A Polygon object with two Points values will still render as long as it has a nonzero StrokeThickness value and a non-null Stroke value, but you could accomplish that same result with a Line object. A Polygon that has only one point will not render.

The following example shows how to use a Polygon object to create a triangle.

<Canvas
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <!-- This polygon shape uses predefined 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.

Polygon illustration

Rectangle.

Reference

Community Additions

ADD
Show:
© 2014 Microsoft