Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-draw-a-line.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

1.5 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Draw a Line 03/30/2017
drawing [WPF], lines
graphics [WPF], lines
lines [WPF], drawing
0513ee01-6b27-4bb3-85f3-3a3e6710d80e

How to: Draw a Line

This example shows you how to draw lines by using the xref:System.Windows.Shapes.Line element.

To draw a line, create a xref:System.Windows.Shapes.Line element. Use its xref:System.Windows.Shapes.Line.X1%2A and xref:System.Windows.Shapes.Line.Y1%2A properties to set its start point; and use its xref:System.Windows.Shapes.Line.X2%2A and xref:System.Windows.Shapes.Line.Y2%2A properties to set its end point. Finally, set its xref:System.Windows.Shapes.Shape.Stroke%2A and xref:System.Windows.Shapes.Shape.StrokeThickness%2A because a line without a stroke is invisible.

Setting the xref:System.Windows.Shapes.Shape.Fill%2A element for a line has no effect, because a line has no interior.

The following example draws three lines inside a xref:System.Windows.Controls.Canvas element.

Example

[!code-xamldrawingwithshapeelements#LineExample1]

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

See also