Bidirectional WPF: animate in stages?

In my current application, I have this little animation. It does a full 360 degree rotation of the canvas and works great.

<DoubleAnimation
 Storyboard.TargetName="WaitCanvas" 
 Storyboard.TargetProperty="(Canvas.RenderTransform).(TransformGroup.Children)[0]  
 .(RotateTransform.Angle)" 
 From="0" To="360" Duration="0:0:2"
 AutoReverse="False" RepeatBehavior="Forever" />

But what I want to do is not smooth animation, but animation - 22.5 degrees each. How can I do that?

+3
source share
2 answers

You can use DoubleAnimationUsingKeyFramesand make two keyframes for each increment of 22.5 degrees at the same time.

+4
source

Even simpler, use the DoubleAnimation "By" property, as in:

<DoubleAnimation 
 Storyboard.TargetName="WaitCanvas"  
 Storyboard.TargetProperty="(Canvas.RenderTransform).(TransformGroup.Children)[0]   
 .(RotateTransform.Angle)"  
 From="0" To="360" By="22.5" Duration="0:0:2"
 AutoReverse="False" RepeatBehavior="Forever" />
-2
source

Source: https://habr.com/ru/post/1719735/


All Articles