Я следил за этим вопросом, чтобы сделать цвет анимация.
Я могу создать анимацию, и она работает нормально, пока анимация не запустится снова. Есть момент, когда кажется, что анимация была запущена/остановлена на мгновение. Я хочу, чтобы анимация работала гладко, чтобы в цветах не отображались эффекты перезапуска. Возможно ли это сделать?
Я использую следующий код:
<Storyboard x:Key="GradientAnimation"
RepeatBehavior="Forever"
Storyboard.TargetName="BackgroundBrush"
SpeedRatio="0.3">
<ColorAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)"
EnableDependentAnimation="True"
BeginTime="-0:0:0.5">
<LinearColorKeyFrame KeyTime="0:0:0" Value="Black"/>
<LinearColorKeyFrame KeyTime="0:0:1" Value="Red"/>
<LinearColorKeyFrame KeyTime="0:0:2" Value="Black"/>
<LinearColorKeyFrame KeyTime="0:0:3" Value="Red"/>
<LinearColorKeyFrame KeyTime="0:0:4" Value="Black"/>
<LinearColorKeyFrame KeyTime="0:0:5" Value="Red"/>
<LinearColorKeyFrame KeyTime="0:0:6" Value="Black"/>
<LinearColorKeyFrame KeyTime="0:0:7" Value="Red"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)"
EnableDependentAnimation="True">
<LinearColorKeyFrame KeyTime="0:0:0" Value="Red"/>
<LinearColorKeyFrame KeyTime="0:0:1" Value="Black"/>
<LinearColorKeyFrame KeyTime="0:0:2" Value="Red"/>
<LinearColorKeyFrame KeyTime="0:0:3" Value="Black"/>
<LinearColorKeyFrame KeyTime="0:0:4" Value="Red"/>
<LinearColorKeyFrame KeyTime="0:0:5" Value="Black"/>
<LinearColorKeyFrame KeyTime="0:0:6" Value="Red"/>
<LinearColorKeyFrame KeyTime="0:0:7" Value="Black"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
И я запускаю эту анимацию в коде программной части:
((Storyboard)Resources["GradientAnimation"]).Begin();
Может быть, есть какой-то метод «замедления», который смешивает начало и конец анимации, чтобы она выглядела плавной, как длинная анимация. Какие-либо предложения?