Export (0) Print
Expand All

PathSegment Class

Represents a segment of a PathFigure object.

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

[LocalizabilityAttribute(LocalizationCategory::None, Readability=Readability::Unreadable)] 
public ref class PathSegment abstract : public Animatable
/** @attribute LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) */ 
public abstract class PathSegment extends Animatable
LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) 
public abstract class PathSegment extends Animatable
This class is abstract; see Inheritance Hierarchy for derived non-abstract classes usable in XAML.

Classes that derive from PathSegment, such as ArcSegment, BezierSegment, and LineSegment, represent specific types of geometric segments.

Freezable Features: Because PathSegment 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 the Freezable Objects Overview.

Notes to Inheritors: Although this class is abstract, it is not publicly extensible.

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.

The following example uses a PathGeometry to create a triangle. The PathGeometry is displayed using a Path element.

<Path Stroke="Black" StrokeThickness="1">
  <Path.Data>
    <PathGeometry>
      <PathGeometry.Figures>
        <PathFigureCollection>
          <PathFigure IsClosed="True" StartPoint="10,100">
            <PathFigure.Segments>
              <PathSegmentCollection>
                <LineSegment Point="100,100" />
                <LineSegment Point="100,50" />
              </PathSegmentCollection>
            </PathFigure.Segments>
          </PathFigure>
        </PathFigureCollection>
      </PathGeometry.Figures>
    </PathGeometry>
  </Path.Data>
</Path>

The following illustration shows the shape created in the previous example.

A triangle created with a PathGeometry


A PathGeometry

The previous example showed how to create a relatively simple shape, a triangle. A PathGeometry can also be used to create more complex shapes, including arcs and curves. For examples, see Create an Elliptical Arc, Create a Cubic Bezier Curve, and Create a Quadratic Bezier Curve.

This example is part of larger sample; for the complete sample, see the Geometries Sample.

More Code

How to: Create a LineSegment in a PathGeometry

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

How to: Create an Elliptical Arc

This example shows how to draw an elliptical arc. To create an elliptical arc, use the PathGeometry, PathFigure, and ArcSegment classes.

How to: Create a Cubic Bezier Curve

This example shows how to create a cubic Bezier curve. To create a cubic Bezier curve, use the PathGeometry, PathFigure, and BezierSegment classes. To display the resulting geometry, use a Path element, or use it with a GeometryDrawing or a DrawingContext. In the following examples, a cubic Bezier curve is drawn from (10, 100) to (300, 100). The curve has control points of (100, 0) and (200, 200).

How to: Create a Quadratic Bezier Curve

This example shows how to create a quadratic Bezier curve. To create a quadratic Bezier curve, use the PathGeometry, PathFigure, and QuadraticBezierSegment classes.

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Freezable
         System.Windows.Media.Animation.Animatable
          System.Windows.Media.PathSegment
             Derived Classes

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