This documentation is archived and is not being maintained.

LineSegment Constructor (Point, Boolean)

Initializes a new instance of the LineSegment class that has the specified end Point and Boolean that determines whether this LineSegment is stroked.

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)

public LineSegment(
	Point point,
	bool isStroked
You cannot use constructors in XAML.


Type: System.Windows.Point

The end point of this LineSegment.

Type: System.Boolean

true to stroke this LineSegment; otherwise, false.

This example shows how to create a line segment. To create a line segment, use the PathGeometry, PathFigure, and LineSegment classes.

The following examples draw a LineSegment from (10, 50) to (200, 70). The following illustration shows the resulting LineSegment; a grid background was added to show the coordinate system.

A LineSegment drawn from (10,50) to (200,700)

A LineSegment in a PathFigurexaml

In Extensible Application Markup Language (XAML), you may use attribute syntax to describe a path.

<Path Stroke="Black" StrokeThickness="1"  
  Data="M 10,50 L 200,70" />

(Note that this attribute syntax actually creates a StreamGeometry, a lighter-weight version of a PathGeometry. For more information, see the Path Markup Syntax page.)

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();

myPathFigure.Segments = myPathSegmentCollection;

PathFigureCollection myPathFigureCollection = new PathFigureCollection();

PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures = myPathFigureCollection;

Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
<Path Stroke="Black" StrokeThickness="1">
      <PathFigure StartPoint="10,50">
        <LineSegment Point="200,70" />

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.

.NET Framework

Supported in: 3.5, 3.0