如何反转 WPF Storyboard 动画?
我在 Expression Blend 4 中的图像上创建了 WPF Storyboard 动画。悬停时,图像逐渐模糊。当鼠标离开图像时,有什么方法可以撤消或反转故事板吗?我可以让它触发 Storyboard.Remove() 但这实际上不会向后播放 Storyboard。
有什么方法可以在 Expression Blend 4 中实现这一目标吗?
I've created a WPF Storyboard animation on an image in Expression Blend 4. On hover, the image gradually blurs. Is there any way I can have the Storyboard be undone or reversed when the mouse leaves the image? I could make it trigger Storyboard.Remove() but that wouldn't actually play through the Storyboard backwards.
Is there any way I can accomplish that within Expression Blend 4?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您使用的是 Blend,因此您应该利用 Blend 对
VisualStateManager
的支持。您所要做的就是描述对象在各种状态下的外观,例如MouseOver
和Normal
以及各种状态之间的转换有多长,以及视觉状态管理器找出如何在状态之间转换。图像没有任何视觉状态,但您可以编辑
Button
模板并将其内容设为图像,然后编辑按钮的状态。我已经完成了此操作并清理了 XAML 以演示该技术:请注意,Blend 会为您完成所有这些工作,但了解 XAML 会有所帮助。这是面向 Blend 的教程:
Since you are using Blend, you should take advantage of Blend's support for the
VisualStateManager
. All you have to do is describe what the object looks like in its various states, likeMouseOver
andNormal
and how long the transitions between various states are, and the visual state manager works out how to transition between states.An image doesn't have any visual states but you can edit a
Button
template and make its content an image and then edit the states for the button. I've done this and cleaned up the XAML to demonstrate the technique:Note that Blend does all this for you but understanding the XAML will help. Here's a Blend-oriented tutorial:
也许解决方案就在这个答案上:
如何使用 C#/WPF 在 MouseEnter 和 MouseLeave 事件上为 ListBox 项目设置动画?
Maybe the solution is on this Answer:
How to animate ListBox Items on MouseEnter and MouseLeave events using C#/WPF?