我有一种风格:
<Style x:Key="StarPathStyle" TargetType="Path">
<Setter Property="StrokeThickness" Value="1"/>
<Setter Property="Stroke" Value="#FF000080"/>
<Setter Property="StrokeStartLineCap" Value="Round"/>
<Setter Property="StrokeEndLineCap" Value="Round"/>
<Setter Property="StrokeLineJoin" Value="Round"/>
<Setter Property="StrokeMiterLimit" Value="1"/>
<Setter Property="Data" Value="F1 M 145.637,174.227L 127.619,110.39L 180.809,70.7577L 114.528,68.1664L 93.2725,5.33333L 70.3262,67.569L 4,68.3681L 56.0988,109.423L 36.3629,172.75L 91.508,135.888L 145.637,174.227 Z"/>
<Setter Property="Fill" Value="#FFFFFF00">
</Setter>
</Style>
一个ListBox,显示了几个项目:
<ListBox Background="LightGray" Margin="8,171.5,8,8">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<Button Content="Hello" />
<Path Style="{StaticResource StarPathStyle}" />
<Ellipse Width="10" Height="20" Fill="Blue" />
<Ellipse Width="20" Height="10" Fill="Blue" />
<Path Style="{StaticResource StarPathStyle}" />
</ListBox>
问题:为什么它适用于WPF但不适用于Silverlight 3.0?
在Silveright上,它提供“ ArgumentException ”,声明“值不在预期范围内。”
.pom。
答案 0 :(得分:0)
不太确定,但我发现通过将“数据”从样式资源移动到XAML文件中,它可以工作:
<Path Style="{StaticResource StarPathStyle}"
Data="F1 M 145.637,174.227L 127.619,110.39L 180.809,70.7577L 114.528,68.1664L 93.2725,5.33333L 70.3262,67.569L 4,68.3681L 56.0988,109.423L 36.3629,172.75L 91.508,135.888L 145.637,174.227 Z" />