Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-draw-a-closed-shape-by-using-the-polygon-element.md
Andy (Steve) De George be103da07e Replace various WPF include files with content (#1335)
* net-current-v30plus-md.md

* net-current-v40plus-md.md

* tla2sharptla-ui-md.md

* tla2sharptla-uiautomation-md.md

* tla2sharptla-winclient-md.md

* tla2sharptla-xaml-md.md

* tlasharptla-ui-md.md

* tlasharptla-uiautomation-md.md

* tlasharptla-winclient-md.md

* tlasharptla-xaml-md.md

* fix warnings
2022-03-16 12:14:11 -04:00

1.6 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Draw a Closed Shape by Using the Polygon Element 03/30/2017
graphics [WPF], Polygon elements
closed shapes [WPF], drawing with Polygon elements
Polygon elements [WPF]
drawing [WPF], closed shapes with Polygon elements
4b0ca008-29ce-48dd-8bc3-f3a20ffca6a6

How to: Draw a Closed Shape by Using the Polygon Element

This example shows how to draw a closed shape by using the xref:System.Windows.Shapes.Polygon element. To draw a closed shape, create a xref:System.Windows.Shapes.Polygon element and use its xref:System.Windows.Shapes.Polygon.Points%2A property to specify the vertices of a shape. A line is automatically drawn that connects the first and last points. Finally, specify a xref:System.Windows.Shapes.Shape.Fill%2A, a xref:System.Windows.Shapes.Shape.Stroke%2A, or both.

Example

In Extensible Application Markup Language (XAML), valid syntax for points is a space-delimited list of comma-separated x- and y-coordinate pairs.

[!code-xamldrawingwithshapeelements#PolygonExample1]

Although the example uses a xref:System.Windows.Controls.Canvas to contain the polygons, you can use polygon elements (and all the other shape elements) with any xref:System.Windows.Controls.Panel or xref:System.Windows.Controls.Control that supports non-text content.

This example is part of a larger sample; for the complete sample, see Shape Elements Sample.