Freigeben über


Polygon

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

<Polygon   .../>

Properties

Canvas.Left, Canvas.Top, Canvas.ZIndex, Clip, Cursor, Effect (Silverlight 3), Fill (Shape), FillRule (Polygon), Grid.Column (Silverlight 2), Grid.ColumnSpan (Silverlight 2), Grid.Row (Silverlight 2), Grid.RowSpan (Silverlight 2), Height (UIElement), HorizontalAlignment (Silverlight 2), Margin (Silverlight 2), MaxHeight (Silverlight 2), MaxWidth (Silverlight 2), MinHeight (Silverlight 2), MinWidth (Silverlight 2), Name (DependencyObject), Opacity (UIElement), OpacityMask, Points (Polygon), Projection (Silverlight 3), RenderTransform, RenderTransformOrigin, Resources, Stretch (Shape), Stroke (Shape), StrokeDashArray, StrokeDashCap, StrokeDashOffset, StrokeEndLineCap, StrokeLineJoin, StrokeMiterLimit, StrokeStartLineCap, StrokeThickness, Style (Silverlight 2), Tag, Triggers, VerticalAlignment (Silverlight 2), Visibility, Width (UIElement)

Managed Equivalent

Polygon

Remarks

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.

Example

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

<Canvas
  xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="https://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.

See Also

Reference