WPF,给颜色SolidColorBrush添加动画

/// <summary>
/// 设置颜色动画
/// </summary>
/// <returns></returns>
private SolidColorBrush ColorAnimation()
{ ColorAnimationUsingKeyFrames colorAnimation = new ColorAnimationUsingKeyFrames();
colorAnimation.Duration = TimeSpan.FromSeconds(1);
colorAnimation.FillBehavior = FillBehavior.Stop;
colorAnimation.KeyFrames.Add(new DiscreteColorKeyFrame(Brushes.Red.Color, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.5))));
colorAnimation.KeyFrames.Add(new DiscreteColorKeyFrame(Brushes.Transparent.Color, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1))));
colorAnimation.KeyFrames.Add(new DiscreteColorKeyFrame(Brushes.Red.Color, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1.5))));
SolidColorBrush background = new SolidColorBrush();
AnimationClock myClock = colorAnimation.CreateClock();
background.ApplyAnimationClock(SolidColorBrush.ColorProperty, myClock);
return background;
}

  

上一篇:20172301 《Java软件结构与数据结构》实验一报告


下一篇:android ScrollView--Linearlayout可以上下拖动