Creates a line between two points in a PathFigure.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Use a PathFigure object to create composite shapes using objects and other segments.
The class does not contain a property for the starting point of the line. The starting point of the line is the end point of the previous segment, or the StartPoint of the PathFigure if no other segments exist.
Freezable Features: Because objects inherit from the Freezable class, they provide several special features: they can be declared as resources, shared among multiple objects, made read-only to improve performance, cloned, and made thread-safe. For more information about the different features that are provided by Freezable objects, see Freezable Objects Overview.
The following examples draw a from (10, 50) to (200, 70). The following illustration shows the resulting ; a grid background was added to show the coordinate system.
In Extensible Application Markup Language (XAML), you may use attribute syntax to describe a path.
In XAML, you may also draw a line segment by using object element syntax. The following is equivalent to the previous XAML example.
PathFigure myPathFigure = new PathFigure(); myPathFigure.StartPoint = new Point(10, 50); LineSegment myLineSegment = new LineSegment(); myLineSegment.Point = new Point(200, 70); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); myPathSegmentCollection.Add(myLineSegment); myPathFigure.Segments = myPathSegmentCollection; PathFigureCollection myPathFigureCollection = new PathFigureCollection(); myPathFigureCollection.Add(myPathFigure); PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; Path myPath = new Path(); myPath.Stroke = Brushes.Black; myPath.StrokeThickness = 1; myPath.Data = myPathGeometry;
This example is part of larger sample; for the complete sample, see the Geometries Sample.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.