Change animation from LinearGradientBrush to SolidColorBrush

Is it possible with animation to change Ellipse.Fill from LinearGradientBrush to SolidColorBrush or change gradient stops in LinearGradientBrush?

+3
source share
2 answers

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

+3
source

You can animate individual gradient stops of a gradient brush (and setting them to the same color will give you a “solid” color) This is an example of a gradient animation set on Panel.Background for some purpose:

<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>
+2
source

Source: https://habr.com/ru/post/1772067/


All Articles