Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

StreamGeometryContext.BezierTo Method

Draws a Bezier curve to the specified point.

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

public abstract void BezierTo(
	Point point1,
	Point point2,
	Point point3,
	bool isStroked,
	bool isSmoothJoin
)

Parameters

point1
Type: System.Windows.Point

The first control point used to specify the shape of the curve.

point2
Type: System.Windows.Point

The second control point used to specify the shape of the curve.

point3
Type: System.Windows.Point

The destination point for the end of the curve.

isStroked
Type: System.Boolean

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

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

ExceptionCondition
InvalidOperationException

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

A cubic Bezier curve is defined by a start point, end point, and two control points. The first control point determines the curvature of the first half of the segment, and the second control point determines the curvature of the second half of the segment.

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 a Bezier curve using the BezierTo method.

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

namespace SDKSample
{
    public partial class StreamGeometryBezierToExample : Page
    {
        public StreamGeometryBezierToExample()
        {

            // 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 Bezier curve using the 3 specifed points where the first two points 
                // are control points and the last point is the destination point for the curve.
                ctx.BezierTo(new Point(100, 0), new Point(200,200), new Point(300,100), 
                             true /* is stroked */, false /* is smooth join */);

            }

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

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

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

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft