Answer the question
In order to leave comments, you need to log in
Why can't I animate the color?
<Ellipse>
<Ellipse.Style>
<Style TargetType="Ellipse">
<Style.Triggers>
<EventTrigger RoutedEvent="Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard TargetProperty="Fill">
<ColorAnimation To="Yellow" Duration="0:0:3" RepeatBehavior="Forever" AutoReverse="True"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
<Ellipse.Triggers>
<EventTrigger RoutedEvent="Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard TargetProperty="Fill">
<ColorAnimation To="Yellow" Duration="0:0:3" RepeatBehavior="Forever" AutoReverse="True"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Ellipse.Triggers>
</Ellipse>
Answer the question
In order to leave comments, you need to log in
You are trying to animate the Fill property with a ColorAnimation, but that property, in the case of a circle being filled with a solid color, contains a SolidColorBrush. In turn, SolidColorBrush contains a Color property that you can animate using ColorAnimation.
Here is your corrected example:
<Ellipse Width="50" Height="50" Fill="#fff">
<Ellipse.Triggers>
<EventTrigger RoutedEvent="Ellipse.Loaded">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)" To="Yellow" Duration="0:0:3" RepeatBehavior="Forever" AutoReverse="True"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Ellipse.Triggers>
</Ellipse>
<Ellipse Width="50" Height="50" Fill="White">
<Ellipse.Triggers>
<EventTrigger RoutedEvent="Ellipse.Loaded">
<BeginStoryboard>
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)" RepeatBehavior="Forever" FillBehavior="Stop">
<DiscreteColorKeyFrame Value="Red" KeyTime="0:0:3"/>
<DiscreteColorKeyFrame Value="White" KeyTime="0:0:3.1"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Ellipse.Triggers>
</Ellipse>
Show full markup.
-------------------------------------------
Exception under debugger (full markup)
------------------------
The first link in Google
https://www.google.ru/?client=opera#newwindow=1&q=..
stackoverflow.com/questions/2248726/wpf-coloranima...
As indicated in the example, everything is ok .
Link about using Google toster.ru/q/320815
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question