我创建了一个 MainMenu 和两个动画:ZoomIn 和 ZoomOut。MainMenu 将充满 Canvas,每个都包含图标。我想要做的是单击一个按钮,当前可见面板会随着 ZoomOut 消失,而单击的面板会随着 ZoomIn 出现。
到目前为止,我已经设法使用以下代码从代码后面调用动画:
Dim ZoomOut As Storyboard = DirectCast(FindResource("storyZoomOut"), Storyboard)
ZoomOut.Begin()
但现在我想让特定的控件设置动画。是否可以同时为两个不同的控件设置动画?同时像 Canvas1 ZoomOut 和 Canvas2 ZoomIn 一样?
<Storyboard x:Key="storyZoomOut">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="pnlCompras">
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="0.8"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0.6"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0.4"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0.2"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0.0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="pnlCompras">
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="1.04"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1.09"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1.15"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="1.3"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="pnlCompras">
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="1.04"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1.09"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1.15"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="1.3"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="pnlCompras">
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="pnlCompras">
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
感谢你的帮助!