简体   繁体   English

在DataTemplate中按下按钮后,对ListBoxItem进行动画处理

[英]Animate ListBoxItem after pressing a button within DataTemplate

I have a ListBox with a DataTemplate for items. 我有一个带有DataTemplate项目的ListBox。 The DataTemplate contains a button. DataTemplate包含一个按钮。 How do I rotate the UIElement represented by the DataTemplate when the button gets pressed? 按下按钮时如何旋转由DataTemplate表示的UIElement? 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. 在Expression Blend中编辑数据模板,在编辑数据模板时创建一个新的StoryBoard,例如“ sbItemAnim”,现在记录您的动画。 then close the storyboard, you'll return to the DataTemplate Edit mode. 然后关闭情节提要,您将返回到DataTemplate编辑模式。

Now Find the Behavior called "ControlStoryboardAction" from Asset pane, Drag and Drop it over your Button. 现在,从“资产”窗格中找到名为“ ControlStoryboardAction”的行为,将其拖放到您的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. 然后将行为配置为在触发事件“点击”时运行,并让它控制您创建的“ sbItemAnim”的故事板,并为ControlStoryboardOption选择“播放”。

Save and test it, Hopefully it'll work with you :) 保存并测试它,希望它可以与您一起使用:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM