I'm trying to display a list of bound data in a then get a Canvas to animate behind each row. I'm having trouble getting a Storyboard to Begin when I place it inside a template. Here is an example of the XAML I have so far:
<ListBox x:Name="MyListBox" Background="Transparent" Foreground="White" Height="200" Width="400" BorderThickness="0" Margin="0">
<ListBox.ItemTemplate>
<DataTemplate x:Name="MySingleDataTemplate">
<StackPanel Orientation="Horizontal" x:Name="MySingleStackPanel" Margin="0">
<StackPanel.Resources>
<Storyboard x:Name="MySingleStoryboard" BeginTime="0:0:1">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Canvas99" Storyboard.TargetProperty="Width"
AutoReverse="True" RepeatBehavior="Forever">
<LinearDoubleKeyFrame Value="0" KeyTime="0:0:0" />
<LinearDoubleKeyFrame Value="400" KeyTime="0:0:3" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</StackPanel.Resources>
<Grid Background="Black" x:Name="MySingleGrid" Margin="0" ShowGridLines="False">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="Col0" Width="300" />
<ColumnDefinition x:Name="Col1" Width="100" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30" x:Name="Row0" />
</Grid.RowDefinitions>
<Canvas Background="{Binding CanvasColour}" Grid.Row="0" Grid.Column="0" x:Name="Canvas99" HorizontalAlignment="Left" />
<TextBlock Grid.Column="0" Grid.Row="0" Text="{Binding Field1}" Margin="0"/>
<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Field2}" Margin="0"/>
</Grid>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
How can I call the equivalent of the C#:
MySingleStoryboard.Begin();
Is there a way I can get it to start from C# or are there some other properties or Triggers I can use in Silverlight? Or am I going about it in completely the wrong way?
thankyou Mike