Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-draw-a-polyline-by-using-the-polyline-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

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 Extensible Application Markup Language (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