WPF C# Animate Linear Gradient Brush起点或终点

WPF C# Animate Linear Gradient Brush start point or end point

如何设置"EndPointProperty"或"StartPointProperty"的动画来为LinearGradientBrush设置动画?

我在 xaml 中有此代码:

<Rectangle x:Name="itemRefl"  >
 <Rectangle.Fill>
  <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
    <GradientStop Offset="0"/>
    <GradientStop Color="White" Offset="0.5"/>
    <GradientStop Offset="1"/>
  </LinearGradientBrush>
 </Rectangle.Fill>
</Rectangle>

我的动画代码是这样的,但无法正常工作。我怎样才能正确地制作这个 属性 的动画?

Storyboard story1 = new Storyboard();
PointAnimation endPointAnim = new PointAnimation()
{
   EasingFunction = new SineEase { EasingMode = EasingMode.EaseInOut },
   From = new Point( 0.0, -0.26),
   To = new Point(0.0, 0.26),
   Duration = new Duration(TimeSpan.FromMilliseconds(500))

};
Storyboard.SetTargetProperty(endPointAnim, new PropertyPath(LinearGradientBrush.EndPointProperty));
story1.Children.Add(endPointAnim);
myelement.BeginStoryboard(story1);

谢谢

运行直接在LinearGradientBrush上做动画:

itemRefl.Fill.BeginAnimation(LinearGradientBrush.EndPointProperty, endPointAnim);