Storyboard storyboard = new Storyboard();//创建故事板
            DoubleAnimation doubleAnimation = new DoubleAnimation();//实例化一个Double类型的动画
            RotateTransform rotate = new RotateTransform();//旋转转换实例
            this.fan.RenderTransform = rotate;//给图片空间一个转换的实例
            storyboard.RepeatBehavior = RepeatBehavior.Forever;//设置重复为 一直重复
            storyboard.SpeedRatio = 2;//播放的数度
            //设置从0 旋转360度
            doubleAnimation.From = 0;
            doubleAnimation.To = 360;
            doubleAnimation.Duration = new Duration(new TimeSpan(0, 0, 2));//播放时间长度为2秒
            Storyboard.SetTarget(doubleAnimation, this.fan);//给动画指定对象
            Storyboard.SetTargetProperty(doubleAnimation,
                new PropertyPath("RenderTransform.Angle"));//给动画指定依赖的属性
            storyboard.Children.Add(doubleAnimation);//将动画添加到动画板中
            storyboard.Begin(this.fan);//启动动画

相关文章:

  • 2022-02-19
  • 2022-12-23
  • 2021-06-25
猜你喜欢
  • 2022-02-04
  • 2021-08-21
  • 2021-09-07
  • 2022-02-24
  • 2022-12-23
  • 2021-11-08
  • 2021-05-20
相关资源
相似解决方案