Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
PathFigure Class
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
PathFigure Class

Represents a subsection of a geometry, a single connected series of two-dimensional geometric segments.

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Visual Basic (Declaration)
<ContentPropertyAttribute("Segments")> _
<LocalizabilityAttribute(LocalizationCategory.None, Readability := Readability.Unreadable)> _
Public NotInheritable Class PathFigure _
    Inherits Animatable _
    Implements IFormattable
Visual Basic (Usage)
Dim instance As PathFigure
C#
[ContentPropertyAttribute("Segments")]
[LocalizabilityAttribute(LocalizationCategory.None, Readability = Readability.Unreadable)]
public sealed class PathFigure : Animatable, 
    IFormattable
Visual C++
[ContentPropertyAttribute(L"Segments")]
[LocalizabilityAttribute(LocalizationCategory::None, Readability = Readability::Unreadable)]
public ref class PathFigure sealed : public Animatable, 
    IFormattable
JScript
public final class PathFigure extends Animatable implements IFormattable
XAML Object Element Usage
<PathFigure>
  Segments
</PathFigure>

A PathGeometry is made up of one or more figures, represented by the PathFigure class. Each figure is itself made up of one or more segments, defined by the PathSegment class.

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.

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

(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.

C#
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;
XAML
<Path Stroke="Black" StrokeThickness="1">
  <Path.Data>
    <PathGeometry>
      <PathFigure StartPoint="10,50">
        <LineSegment Point="200,70" />
      </PathFigure>
    </PathGeometry>
  </Path.Data>
</Path>

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

More Code

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.
How to: Create Multiple Subpaths Within a PathGeometry This example shows how to create multiple subpaths in a PathGeometry. To create multiple subpaths, you create a PathFigure for each subpath.
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 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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker