StreamGeometryContext.PolyBezierTo Method (IList<Point>, Boolean, Boolean)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Draws one or more connected Bezier curves.

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

public abstract void PolyBezierTo(
	IList<Point> points,
	bool isStroked,
	bool isSmoothJoin


Type: System.Collections.Generic.IList<Point>

The list of points that specify control points and destination points for one or more Bezier curves. The number of points in this list should be a multiple of three.

Type: System.Boolean

true to make the segment stroked when a Pen is used to render the segment; otherwise, false.

Type: System.Boolean

true to treat the join between this segment and the previous segment as a corner when stroked with a Pen; otherwise, false.

Exception Condition

An attempt was made to add a segment without starting a figure by calling the BeginFigure method.

The first point in points specifies the first control point, the next specifies the second control point, the third point specifies the end point, the next point specifies the first control point of the next curve, and so on.

This method uses the end point of the previous segment as its starting point. If this is the first segment in a figure, it uses the point specified by the BeginFigure method as its start point.

A StreamGeometry cannot be serialized if it contains a Transform or any non-stroked or unfilled segments.

The following example shows how to draw multiple connected Bezier curves using the PolyBezierTo method.

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace SDKSample
    public partial class StreamGeometryPolyBezierToExample : Page
        public StreamGeometryPolyBezierToExample()
            // Create a path to draw a geometry with.
            Path myPath = new Path();
            myPath.Stroke = Brushes.Black;
            myPath.StrokeThickness = 1;

            // Create a StreamGeometry to use to specify myPath.
            StreamGeometry geometry = new StreamGeometry();
            geometry.FillRule = FillRule.EvenOdd;

            // Open a StreamGeometryContext that can be used to describe this StreamGeometry 
            // object's contents.
            using (StreamGeometryContext ctx = geometry.Open())
                // Set the begin point of the shape.
                ctx.BeginFigure(new Point(10, 100), true /* is filled */, false /* is closed */);

                // Create a collection of Point structures that will be used with the PolyBezierTo 
                // Method to create the Bezier curve.
                List<Point> pointList = new List<Point>();

                // First Bezier curve is specified with these three points.

                // First control point for first Bezier curve.
                pointList.Add(new Point(100,0));

                // Second control point for first Bezier curve.
                pointList.Add(new Point(200, 200));

                // Destination point for first Bezier curve.
                pointList.Add(new Point(300, 100));

                // Second Bezier curve is specified with these three points.

                // First control point for second Bezier curve.
                pointList.Add(new Point(400, 0));

                // Second control point for second Bezier curve.
                pointList.Add(new Point(500, 200));

                // Destination point for second Bezier curve.
                pointList.Add(new Point(600, 100));

                // Create a Bezier curve using the collection of Point Structures.
                ctx.PolyBezierTo(pointList, true /* is stroked */, false /* is smooth join */);


            // Freeze the geometry (make it unmodifiable)
            // for additional performance benefits.

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

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

.NET Framework
Available since 3.0
Return to top