Sdílet prostřednictvím


LineSegment

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Represents a line drawn between two points, which can be part of a PathFigure object in Path data.

<LineSegment   .../>

Managed Equivalent

LineSegment

Remarks

LineSegment is the simplest segment type. The start of the line is either the start point or the last point of the previous segment.

You can also generate the simple shape of a line by using the Line object. LineSegment is particularly intended for drawing a line in what is typically a more complex geometry group.

Example

The following example creates a simple PathGeometry object composed of a single PathFigure object with a LineSegment and displays it by using a Path element. The PathFigure object's StartPoint property is set to 10,20 and a LineSegment is defined with an end point of 100,130. The following illustration shows the PathGeometry created by this example.

A PathGeometry

Diagonal line.

<Canvas  
  xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"> 
  
  <Path Stroke="Black" StrokeThickness="1">
    <Path.Data>
      <PathGeometry>
        <PathGeometry.Figures>
          <PathFigure StartPoint="10,20">
            <PathFigure.Segments>
              <LineSegment Point="100,130"/>
            </PathFigure.Segments>
          </PathFigure>
        </PathGeometry.Figures>
      </PathGeometry>
    </Path.Data>
  </Path> 
</Canvas>