Export (0) Print
Expand All

LineGeometry Class

Represents the geometry of a line. This class cannot be inherited.

Namespace: System.Windows.Media
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public sealed class LineGeometry : Geometry
public final class LineGeometry extends Geometry
public final class LineGeometry extends Geometry
<LineGeometry .../>

To create multiple connected lines, use a LineSegment or Polyline segment with a PathFigure and PathGeometry classes.

Freezable Features: Because it inherits from the Freezable class, the LineGeometry class provides several special features: LineGeometry objects 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 provided by Freezable objects, see the Freezable Objects Overview.

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

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

<Path Stroke="Black" StrokeThickness="1" >
  <Path.Data>
    <LineGeometry StartPoint="10,20" EndPoint="100,130" />
  </Path.Data>
</Path>

LineGeometry myLineGeometry = new LineGeometry();
myLineGeometry.StartPoint = new Point(10,20);
myLineGeometry.EndPoint = new Point(100,130);

Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myLineGeometry;

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


A LineGeometry

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

More Code

How to: Create a Composite Shape

This example shows how to create composite shapes using Geometry objects and display them using a Path element. In the following example, a LineGeometry, EllipseGeometry, and a RectangleGeometry are used with a GeometryGroup to create a composite shape. The geometries are then drawn using a Path element.

How to: Create a Shape by Using a PathGeometry

This example shows how to create a shape using the PathGeometry class. PathGeometry objects are composed of one or more PathFigure objects; each PathFigure represents a different "figure" or shape. Each PathFigure is itself composed of one or more PathSegment objects, each representing a connected portion of the figure or shape. Segment types include LineSegment, ArcSegment, and BezierSegment.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft