我想要为控件的 fill 属性使用的 GradientBrush(在我的例子中为 LinearGradientBrush)设置动画。我尝试更改 Storyboard中的渐变停止值(偏移或颜色),但它似乎不起作用。我以网格背景作为示例:
<Grid x:Name="LogoGrid" Height="512" Width="512">
<Grid.Background>
<LinearGradientBrush x:Name="LogoBackgroundBrush" StartPoint="0 0" EndPoint="1 1">
<GradientStop x:Name="Stop0" Color="Transparent" Offset="0" />
<GradientStop x:Name="Stop1" Color="#80FFFFFF" Offset="0.5" />
<GradientStop x:Name="Stop2" Color="Transparent" Offset="1" />
</LinearGradientBrush>
</Grid.Background>
</Grid>
Storyboard:
<Storyboard x:Key="LoadingStoryBoard">
<ColorAnimationUsingKeyFrames Storyboard.TargetName="LogoGrid"
Storyboard.TargetProperty="(UIElement.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)"
RepeatBehavior="Forever" EnableDependentAnimation="True">
<LinearColorKeyFrame Value="#40000000" KeyTime="0:0:1" />
<LinearColorKeyFrame Value="#A0FFFFFF" KeyTime="0:0:2" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
最佳答案
您是否确定将 EnableDependentAnimation
设置为 true
?
您可以查看my answer到另一个类似的问题以获得完整的示例。
关于xaml - 在 UWP 中设置 GradientBrush 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40492454/