我为DoubleAnimation
设置DropShadowEffect
来更改Blur Radius
上下生成一个发光的动画阴影:
DropShadowEffect DS = new DropShadowEffect();
/// Whatever DS settings here
Target.Effect = DS;
DoubleAnimation DSr = new DoubleAnimation(0, 25, new Duration(TimeSpan.FromMilliseconds(500)));
DSr.AutoReverse = true;
DSr.RepeatBehavior = RepeatBehavior.Forever;
DS.BeginAnimation(DropShadowEffect.BlurRadiusProperty, DSr);
向前迈出一步需要20
毫秒,总时间为500
毫秒。
是否可以每10
毫秒执行一次反向操作,总时间为250
毫秒(正常速度的两倍)。
答案 0 :(得分:1)
我想我可以使用Completed
事件做这样的事情:
DoubleAnimation animation = new DoubleAnimation(0.0, 1.0);
animation.Duration = TimeSpan.FromMilliseconds(500);
animation.Completed += (s, e) =>
{
If (target.opacity == 1)
{
animation.From = 1.0;
animation.To = 0.0;
animation.Duration = TimeSpan.FromMilliseconds(250);
element.BeginAnimation(OpacityProperty, animation);
}
else
{
animation.From = 0.0;
animation.To = 1.0;
animation.SpeedRatio = TimeSpan.FromMilliseconds(500);
element.BeginAnimation(OpacityProperty, animation);
}
}
element.BeginAnimation(OpacityProperty, animation);