Technology is not science. RSS Feed


PathGeometry Figures Property XAML Attribute Syntax in Silverlight

The MSDN documentation is incorrect. In the current released version of Silverlight 2, 2.0.31005.0, you cannot use attribute syntax for the Figures property of a PathGeometry in XAML. For instance, the following will fail, throwing a XamlParseException.

<Path Fill="Black">
<Path.Data>
<PathGeometry Figures="M0,0L9,0 9,9 0,9Z" />
</Path.Data>
</Path>

This is true for path geometries used in clipping regions as well. The following will fail in the same way.

<Rectangle Width="23" Height="23" Fill="Black">
<Rectangle.Clip>
<PathGeometry Figures="M0,0L9,0 9,9 0,9Z" />
</Rectangle.Clip>
</Rectangle>

Instead, you must use the more verbose element syntax.

<Rectangle Width="23" Height="23" Fill="Black">
<Rectangle.Clip>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure StartPoint="0,0" IsClosed="True">
<LineSegment Point="9,0" />
<LineSegment Point="9,9" />
<LineSegment Point="0,9" />
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Rectangle.Clip>
</Rectangle>

This is not true for the Data property of a Path. The following will work as expected.

<Path Fill="Black" Data="M0,0L9,0 9,9 0,9Z" />
 
Posted by Chris Idzerda | 1 Comments | Trackback Url | Bookmark with:        
Tags: Work

Links to this Post

Comments

Thursday, 4 Dec 2008 01:38 by Jim B-G
You're right about the documentation being incorrect. I believe it is possible to use the path markup syntax for the Clip directly, since it's of type Geometry. An alternative to the verbose method would be something like: <Rectangle Width="23" Height="23" Fill="Black" Clip="M0,0L9,0 9,9 0,9Z" />

Name:
URL:
Email:
Comments:

CAPTCHA Image Validation