5

任何知道答案的人的快速简单点:

以下 Xaml 路径在 WPF 中运行良好,但在 Silverlight 中崩溃。我可以在 Kaxaml 中验证这种行为。

路径代码是

<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>

例外是脚本错误

Silverlight 应用程序中未处理的错误。无法从文本“m 1 2 l 4.0525 5.2361 l 4.0527 -5.2361 z”创建 System.Windows.Media.PathFigureCollection

它应该像这样绘制一个三角形:

在此处输入图像描述

有任何想法吗?

4

1 回答 1

10

与 WPF 不同,Silverlight 不支持将字符串转换为图形。


我在 Expression Blend 中收到以下下划线/悬停错误消息:

在此处输入图像描述


Silverlight 通过 Blend 创作的等效三角形是:

<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" />
于 2012-07-04T15:29:20.190 回答