我该如何反转动画 [英] How can i reverse the animation
本文介绍了我该如何反转动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
如果有人能告诉我如何使此代码在第二次单击时反向工作,我将非常高兴.将该矩形调整为较小的大小,并且我希望在第二次单击时使该小矩形重新生长.提前谢谢.
Hy!
I will be very happy if anyone can tell me how can i make this code to work reverse on the second click. The rectangle resize to small, and i want on the second click that this little rectangle grow back. Thanks in advance.
<Window x:Class="asgsag.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Rectangle Name="Rect" Width="150" Height="250"
Fill="Transparent"
HorizontalAlignment="Left" Margin="0,22,0,12" Stroke="Black">
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Rectangle.MouseLeftButtonDown">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Width"
From="150"
To="50"
Duration="0:0:5"/>
<DoubleAnimation Storyboard.TargetProperty="Height"
From="250"
To="50"
Duration="0:0:5"
/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle>
</Grid>
</Window>
推荐答案
猜想您可以这样来做:
Silverlight:在鼠标进入和离开时创建简单,平滑的反向故事板动画 [ ^ ]
http://www.sunmetablog.co.uk/index.php/2009/silverlight-creating-a-simple-smooth-reverse-storyboard-animation-on-mouse-enter-and-leave/ [ ^ ]
使用VisualState管理器在Blend中似乎也很容易:
http://www.emadibrahim.com/2008/02/14/silverlight -tip-reverse-your-animation/ [
Guess you coulod do it this way instead:
Silverlight: Creating a simple smooth reverse storyboard animation on mouse enter and leave[^]
http://www.sunmetablog.co.uk/index.php/2009/silverlight-creating-a-simple-smooth-reverse-storyboard-animation-on-mouse-enter-and-leave/[^]
Seems to be very easy in Blend also, using the VisualState manager:
http://www.emadibrahim.com/2008/02/14/silverlight-tip-reverse-your-animation/[^]
Lot of other examples found at Google :)
这篇关于我该如何反转动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文