The QuadraticBezierSegment object represents a quadratic Bezier curve between two points. The Point1 and Point2 properties represent the two points.
The following XAML code snippet creates a quadratic Bezier curve by setting Point1 and Point2 properties of a QuadraticBezierSegment.
|
A Path object is used to draw Bezier curves by setting a PathGeomerty as Path.Data. The following code snippet creates a Path and sets a QuadraticBezierSegment as a part of PathFigure.Segments.
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure StartPoint="10,100">
<PathFigure.Segments>
<PathSegmentCollection>
<QuadraticBezierSegment Point1="50,200" Point2="200,50" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path> |
The output looks as in Figure 1.
Figure 1
We can paint a Bezier curve by simply painting the path using the Fill method. The following code snippet has been changed from the previous code to fill the path.
|
The new output looks as in Figure 2.

Figure 2
The following code snippet creates a quadratic Bezier segment dynamically, as shown in Figure 2.
{
PathFigure pthFigure = new PathFigure();
pthFigure.StartPoint = new Point(10, 100);
QuadraticBezierSegment qbzSeg = new QuadraticBezierSegment();
qbzSeg.Point1 = new Point(50, 200);
qbzSeg.Point2 = new Point(200, 50);
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(qbzSeg);
pthFigure.Segments = myPathSegmentCollection;
PathFigureCollection pthFigureCollection = new PathFigureCollection();
pthFigureCollection.Add(pthFigure);
PathGeometry pthGeometry = new PathGeometry();
pthGeometry.Figures = pthFigureCollection;
Path arcPath = new Path();
arcPath.Stroke = new SolidColorBrush(Colors.Black);
arcPath.StrokeThickness = 1;
arcPath.Data = pthGeometry;
arcPath.Fill = new SolidColorBrush(Colors.Yellow);
LayoutRoot.Children.Add(arcPath);
} |

Ehtesham MehmoodPosted Feb 22, 2014, 7:56 PM
Mahesh sir please write article about C# programming language ? what c# can do for you ? please explain in your words i am lover of your website and also lover of C# language so want to know more and more about C# power ?