Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-draw-a-polyline-by-using-the-polyline-element.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

2.5 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Draw a Polyline by Using the Polyline Element 03/30/2017
connected lines [WPF]
polylines [WPF], drawing
graphics [WPF], polylines
lines [WPF], connected (see polylines)
drawing [WPF], polylines
65db8935-d047-4295-87c4-b427ff3ad293

How to: Draw a Polyline by Using the Polyline Element

This example shows how to draw a polyline, which is a series of connected lines, by using the xref:System.Windows.Shapes.Polyline element.

To draw a polyline, create a xref:System.Windows.Shapes.Polyline element and use its xref:System.Windows.Shapes.Polyline.Points%2A property to specify the shape vertices. Finally, use the xref:System.Windows.Shapes.Shape.Stroke%2A and xref:System.Windows.Shapes.Shape.StrokeThickness%2A properties to describe the polyline outline because a line without a stroke is invisible.

Note

Because the xref:System.Windows.Shapes.Polyline element is not a closed shape, the xref:System.Windows.Shapes.Shape.Fill%2A property has no effect, even if you deliberately close the shape outline. To create a closed shape with a xref:System.Windows.Shapes.Shape.Fill%2A, use a xref:System.Windows.Shapes.Polygon element.

The following example draws two xref:System.Windows.Shapes.Polyline elements inside a xref:System.Windows.Controls.Canvas.

Example

In [!INCLUDETLA#tla_xaml], valid syntax for points is a space-delimited list of comma-separated x- and y-coordinate pairs.

[!code-xamldrawingwithshapeelements#PolylineExample1]

Although this example uses a xref:System.Windows.Controls.Canvas to contain the polylines, you can use polyline 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.

See also