Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight - how to auto begin a Storyboard inside a <ListBox.ItemTemplate>
    text
    copied!<p>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:</p> <pre><code> &lt;ListBox x:Name="MyListBox" Background="Transparent" Foreground="White" Height="200" Width="400" BorderThickness="0" Margin="0"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate x:Name="MySingleDataTemplate"&gt; &lt;StackPanel Orientation="Horizontal" x:Name="MySingleStackPanel" Margin="0"&gt; &lt;StackPanel.Resources&gt; &lt;Storyboard x:Name="MySingleStoryboard" BeginTime="0:0:1"&gt; &lt;DoubleAnimationUsingKeyFrames Storyboard.TargetName="Canvas99" Storyboard.TargetProperty="Width" AutoReverse="True" RepeatBehavior="Forever"&gt; &lt;LinearDoubleKeyFrame Value="0" KeyTime="0:0:0" /&gt; &lt;LinearDoubleKeyFrame Value="400" KeyTime="0:0:3" /&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/StackPanel.Resources&gt; &lt;Grid Background="Black" x:Name="MySingleGrid" Margin="0" ShowGridLines="False"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition x:Name="Col0" Width="300" /&gt; &lt;ColumnDefinition x:Name="Col1" Width="100" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="30" x:Name="Row0" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;Canvas Background="{Binding CanvasColour}" Grid.Row="0" Grid.Column="0" x:Name="Canvas99" HorizontalAlignment="Left" /&gt; &lt;TextBlock Grid.Column="0" Grid.Row="0" Text="{Binding Field1}" Margin="0"/&gt; &lt;TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Field2}" Margin="0"/&gt; &lt;/Grid&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; </code></pre> <p>How can I call the equivalent of the C#:</p> <pre><code>MySingleStoryboard.Begin(); </code></pre> <p>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?</p> <p>thankyou Mike</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload