Jan
13
2011
Drawing with Path is most flexible in Silverlight, you can create a more complicated geometry using path. There are two ways: using the Mini-Language Path or creating a PathGeometry object. In following example we'll draw two elliptical arcs by above ways.
<StackPanel orientation="Horizontal">
<!--Draw two elliptical arc with Mini-Language Path-->
<Path Stroke="Blue" StrokeThickness="2"
Data="M 10,100 A 50,25,0,1,1 100,100"/>
<!--Draw two elliptical arc with PathGeometry object-->
<Path Stroke="Blue" StrokeThickness="2">
<Path.Data>
<PathGeometry>
<PathFigure
StartPoint="10,100">
<ArcSegment Point="100,100"
Size="50,25" RotationAngle="0"
IsLargeArc="True" SweepDirection="Clockwise" />
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
</StackPanel>
Obviously, using the Mini-Language Path syntax is easier,but more difficult to understand compared using PathGeometry object. Here move Command M corresponds the StartPoint property, drawing command A corresponds the ArcSegment object, the parameters of drawing command A in the object corresponds the ones of the ArcSegment property one by one, so they get the same effect.
Essentially speaking, Path is also a Shape object, but using Path Shape objects can create more complex than the other two-dimensional graphics. Path can also be used as a drawing container, which allows any shape of the Geometry object tos be contained in it by setting its Path.Data property.
I wonder if you have noticed that, Drawing with Path in Flex 4 is similar in Silverlight, both of them can defined with the mini-language syntax, but Flex 4 doesn't support drawing elliptical arc command.
原文:http://www.riafan.com/article/silverlight/draw-with-path.html