This documentation is archived and is not being maintained.

PolyBezierSegment Class

Represents one or more cubic Bezier curves.

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

Public NotInheritable Class PolyBezierSegment _
	Inherits PathSegment
Dim instance As PolyBezierSegment
<PolyBezierSegment .../>

Use a PathFigure object to store PolyBezierSegment objects and other segments.

A cubic Bezier curve is defined by four points: a start point, an end point and two control points. A PolyBezierSegment specifies one or more cubic Bezier curves by setting the Points property to a collection of points. For every three points in the collection, the first and second points specify the two control points of the curve and the third point specifies the end point. Note that no start point for the curve is specified because start point is the same as the end point of the last segment.

The two control points of a cubic Bezier curve behave like magnets, attracting portions of what would otherwise be a straight line toward themselves and producing a curve. The first control point affects the beginning portion of the curve; the second control point affects the ending portion of the curve. Note that the curve doesn't necessarily pass through either of the control points; each control point moves its portion of the line toward itself, but not through itself.

The following example shows how to use a PolyBezierSegment to draw two cubic Bezier curves.

<Page xmlns=""
      <Path Stroke="Black" StrokeThickness="1">

                <!-- The StartPoint specifies the starting point of the first curve. -->
                <PathFigure StartPoint="10,100">

                      <!-- The PolyBezierSegment specifies two cubic Bezier curves.
                           The first curve is from 10,100 (start point specified above)
                           to 300,100 with a control point of 0,0 and another control
                           point of 200,0. The second curve is from 300,100 
                           (end of the last curve) to 600,100 with a control point of 300,0
                           and another control point of 400,0. -->
                      <PolyBezierSegment Points="0,0 200,0 300,100 300,0 400,0 600,100" />
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace SDKSample
    public partial class PolyBezierSegmentExample : Page
        public PolyBezierSegmentExample()

            // Create a PathFigure to be used for the PathGeometry of myPath.
            PathFigure myPathFigure = new PathFigure();

            // Set the starting point for the PathFigure specifying that the 
            // geometry starts at point 10,100.
            myPathFigure.StartPoint = new Point(10, 100);

            // Create a PointCollection that holds the Points used to specify  
            // the points of the PolyBezierSegment below.
            PointCollection myPointCollection = new PointCollection(6);
            myPointCollection.Add(new Point(0, 0));
            myPointCollection.Add(new Point(200, 0));
            myPointCollection.Add(new Point(300, 100));
            myPointCollection.Add(new Point(300, 0));
            myPointCollection.Add(new Point(400, 0));
            myPointCollection.Add(new Point(600, 100));

            // The PolyBezierSegment specifies two cubic Bezier curves. 
            // The first curve is from 10,100 (start point specified by the PathFigure) 
            // to 300,100 with a control point of 0,0 and another control point  
            // of 200,0. The second curve is from 300,100 (end of the last curve) to  
            // 600,100 with a control point of 300,0 and another control point of 400,0.
            PolyBezierSegment myBezierSegment = new PolyBezierSegment();
            myBezierSegment.Points = myPointCollection;

            PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();

            myPathFigure.Segments = myPathSegmentCollection;

            PathFigureCollection myPathFigureCollection = new PathFigureCollection();

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

            // Create a path to draw a geometry with.
            Path myPath = new Path();
            myPath.Stroke = Brushes.Black;
            myPath.StrokeThickness = 1;

            // specify the shape (quadratic Bezier curve) of the path using the StreamGeometry.
            myPath.Data = myPathGeometry;

            // Add path shape to the UI.
            StackPanel mainPanel = new StackPanel();
            this.Content = mainPanel;

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