Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this Xaml Path crash silverlight?

Quick easy points for anyone who knows the answer:

The following Xaml path works fine in WPF but crashes in Silverlight. I can verify this behaviour in Kaxaml.

The path code is

<Path Fill="#FFEDEDED" StrokeThickness="1" Stroke="#FFA3A3A3" Opacity="0.7" 
                VerticalAlignment="Center" HorizontalAlignment="Center" >
    <Path.Data>
        <PathGeometry Figures="m 1 2 l 4.0525 5.2361 l 4.0527 -5.2361 z "/>
    </Path.Data>
</Path>

The exception is a script error

Unhandled error in Silverlight Application. Failed to create a System.Windows.Media.PathFigureCollection from the text 'm 1 2 l 4.0525 5.2361 l 4.0527 -5.2361 z'

Its supposed to draw a triangle like so:

enter image description here

Any ideas?

like image 404
Dr. Andrew Burnett-Thompson Avatar asked Jul 04 '12 15:07

Dr. Andrew Burnett-Thompson


1 Answers

Unlike WPF Silverlight does not support converting a string to Figures.


I got the following underline/hover error message in Expression Blend:

enter image description here


The equivalent triangle, authored via Blend, for Silverlight is:

<Path Fill="#FFEDEDED" StrokeThickness="1" Stroke="#FFA3A3A3" Opacity="0.7" 
                VerticalAlignment="Center" HorizontalAlignment="Center"
                Data="m 1 2 l 4.0525 5.2361 l 4.0527 -5.2361 z" />
like image 87
Gone Coding Avatar answered Oct 04 '22 01:10

Gone Coding