Handling the BezierSegment as path in Silverlight

This small sample will show you the possibilities of Silverlights (and WPFs) BezierSegment class. To draw a bezier curve you have to encapsulate the BezierSegment as part of a Path element as shown in the following lines of code:

1 <Path x:Name="Curve" Stroke="#FFFFFFFF" StrokeThickness="2"> 2 <Path.Data> 3 <PathGeometry> 4 <PathGeometry.Figures> 5 <PathFigureCollection> 6 <PathFigure x:Name="Figure" StartPoint="27,56"> 7 <PathFigure.Segments> 8 <PathSegmentCollection> 9 <BezierSegment x:Name="Bezier" Point1="227,156" Point2="267,36" Point3="380,30" /> 10 </PathSegmentCollection> 11 </PathFigure.Segments> 12 </PathFigure> 13 </PathFigureCollection> 14 </PathGeometry.Figures> 15 </PathGeometry> 16 </Path.Data> 17 </Path> 18

The curve itself is rendered using four points: the StartPoint attribute of the PathFigure element and the three points Point1, Point2 and Point3 of the BezierSegment. Try to play around with this sample and feel free to have a look into the sources.

Get Microsoft Silverlight
Comments are closed.