Animate ListBoxItem after pressing a button within DataTemplate
I have a ListBox with a DataTemplate for items. The开发者_Go百科 DataTemplate contains a button. How do I rotate the UIElement represented by the DataTemplate when the button gets pressed? Any help greatly appreciated.
I Guess the easiest way to implement what you need is as follows:
Edit the DataTemplate in Expression Blend, While editing the DataTemplate Create a new StoryBoard name it for example "sbItemAnim", now record your animation. then close the storyboard, you'll return to the DataTemplate Edit mode.
Now Find the Behavior called "ControlStoryboardAction" from Asset pane, Drag and Drop it over your Button.
Then Configure the Behavior to run when the Event "Clicked" is fired, and Let it control the storyboard that you've created "sbItemAnim", and Choose "Play" for the ControlStoryboardOption.
Save and test it, Hopefully it'll work with you :)
精彩评论