Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-line-using-a-linegeometry.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.2 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Create a Line Using a LineGeometry 03/30/2017
csharp
vb
graphics [WPF], lines
41231b22-1f74-4c26-a8e7-a55b29f8f6bd

How to: Create a Line Using a LineGeometry

This example shows how to use the xref:System.Windows.Media.LineGeometry class to describe a line. A xref:System.Windows.Media.LineGeometry is defined by its start and end points.

Example

The following example shows how to create and render a xref:System.Windows.Media.LineGeometry. A xref:System.Windows.Shapes.Path element is used to render the line. Since a line has no area, the xref:System.Windows.Shapes.Path object's xref:System.Windows.Shapes.Shape.Fill%2A is not specified; instead the xref:System.Windows.Shapes.Shape.Stroke%2A and xref:System.Windows.Shapes.Shape.StrokeThickness%2A properties are used.

[!code-xamlGeometryOverviewSamples_snip#GraphicsMMLineGeometryExample]

[!code-csharpGeometryOverviewSamples_procedural_snip#GraphicsMMLineGeometryExample] [!code-vbGeometryOverviewSamples_procedural_snip#GraphicsMMLineGeometryExample]

A LineGeometry
A LineGeometry drawn from (10,20) to (100,130)

Other simple geometry classes include xref:System.Windows.Media.LineGeometry and xref:System.Windows.Media.EllipseGeometry. These geometries, as well as more complex ones, can also be created using a xref:System.Windows.Media.PathGeometry or xref:System.Windows.Media.StreamGeometry. For more information, see the Geometry Overview.

See also