如何设置"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);