Animation change from LinearGradientBrush to SolidColorBrush

不想你离开。 提交于 2020-01-02 07:21:06

问题


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


回答1:


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




回答2:


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>


来源:https://stackoverflow.com/questions/4050032/animation-change-from-lineargradientbrush-to-solidcolorbrush

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!