Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animation change from LinearGradientBrush to SolidColorBrush

Is it possible with an animation to change the Ellipse.Fill from a LinearGradientBrush to a SolidColorBrush or change the gradientStops within the LinearGradientBrush?

like image 231
Johan Alkstål Avatar asked Dec 06 '25 11:12

Johan Alkstål


2 Answers

Maybe you should use two ellipses and dynamically change their opacity.

like image 126
Y.Yanavichus Avatar answered Dec 08 '25 11:12

Y.Yanavichus


You can animate the individual gradient stops of a gradient brush (and by setting them to the same color, you'd get a 'solid' color) This is an example of animating the gradient set to the Panel.Background of some target:

<Storyboard>
  <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).
                    (GradientBrush.GradientStops)[0].(GradientStop.Color)"
                                Storyboard.TargetName="sometarget">
    <EasingColorKeyFrame KeyTime="0"
                         Value="Blue" />
  </ColorAnimationUsingKeyFrames>
  <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).
                    (GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                Storyboard.TargetName="sometarget">
    <EasingColorKeyFrame KeyTime="0"
                         Value="Green" />
  </ColorAnimationUsingKeyFrames>
</Storyboard>
like image 25
aL3891 Avatar answered Dec 08 '25 10:12

aL3891



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!