views:

245

answers:

2

I've got a style:

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

And a ListBox that shows a few items:

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

Question: Why does it work on WPF but not on Silverlight 3.0?

On Silveright it gives "ArgumentException" stating that "Value does not fall within the expected range."

.pom.

A: 

Check this out and see if it has helpful info.

kek444
A: 

Not really sure, but I found by moving the "Data" from the styling resource and into the XAML file, it works:

<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" />
scottmarlowe