我有以下情节提要:编程扭转故事板
<Window.Resources>
<Storyboard x:Key="ButtonsAnim">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="topRightButton" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="-100"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="topRightButton" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="100"/>
...
它基本上是将一些按钮画布周围。
这是启动动画代码:
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
Storyboard sb = (Storyboard)Resources["ButtonsAnim"];
storyBoard = sb;
storyBoard.Begin(this, true);
}
我所试图做的是重新设置动画,当我点击一个按钮,隐藏的窗口。当窗口重新出现时,动画应该从头开始。
我尝试使用storyBoard.Begin(this,true)时,应用程序再次出现,但对于第一毫秒的按钮处于其最后位置。
我然后试图storyBoard.seek(TimeSpan.Zero)隐藏窗口之前,但它未能:
System.Windows.Media.Animation 警告:6:无法,因为指定的故事板执行操作 是 从未应用于此对象的 互动控制。行动=“寻求”; Storyboard ='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode ='24901833'; Storyboard.Type ='System.Windows.Media.Animation.Storyboard'; TargetElement ='System.Windows.Media.Animation.Storyboard'; TargetElement.HashCode ='24901833'; TargetElement.Type =“System.Windows.Media.Animation.Storyboard”
我还试图storyBoard.remove(本)隐藏窗口之前,相同的效果:所述按钮处于它们的最后位置。
任何想法?
谢谢。
停止做反向的动画效果 - 但显然它是瞬间的,而不是反其动画。 – McGarnagle 2012-11-20 00:42:03