WPF中如何用Storyboard
<Storyboard x:Key="Storyboard1"><DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="grid"><EasingDoubleKeyFrame KeyTime="0" Value="1"/><EasingDoubleKeyFrame KeyTime="0:0:1" Value="-1"/><EasingDoubleKeyFrame KeyTime="0:0:2" Value="-1"/></DoubleAnimationUsingKeyFrames></Storyboard>
Storyboard keyFrameboard = new Storyboard(); DoubleAnimationUsingKeyFrames dakeyframe = new DoubleAnimationUsingKeyFrames(); Storyboard.SetTarget(dakeyframe, icCurrent); Storyboard.SetTargetProperty(dakeyframe, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)")); dakeyframe.BeginTime = new TimeSpan(0, 0, 0); EasingDoubleKeyFrame edKeyFrame = new EasingDoubleKeyFrame(); edKeyFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1)); edKeyFrame.Value = -1; dakeyframe.KeyFrames.Add(edKeyFrame); keyFrameboard.Children.Add(dakeyframe); keyFrameboard.Begin();
<Canvas x:Name="canvasBottom" Width="500" Height="500" Background="Gray" Grid.Row="1"> <my:ImageContainer x:Name="ic" Width="200" Height="200" > <my:ImageContainer.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </my:ImageContainer.RenderTransform> </my:ImageContainer> </Canvas>