ListboxItem Storyboard Animation
I have a Listbox that is declared with this:
<ListBox Height="694" HorizontalAlignment="Left" x:Name="listBox1"
ItemContainerStyle="{StaticResource ListBoxItemStyle1}" />
ListBoxItemStyle1 is a simple style to which I've added a Storyboard. My question is, h开发者_JAVA技巧ow can I play this storyboard when the user selects the item? I want the selectedListBoxItem to animate but can't seem to access the Storyboard (called sb) from the code-behind as the compiler claims it does not exist.
You can do this by putting an EventTrigger in your Style. Not knowing your specific XAML, here's a generalized example:
<Style ... >
<!--[etc...]-->
<Style.Triggers>
<EventTrigger RoutedEvent="Selected">
<BeginStoryboard>
<Storyboard ...
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
加载中,请稍侯......
精彩评论