我有一个LinearGradientBrush用作opacityymask,我想让我的动画旋转渐变,所以我试图动画的起点和终点的位置,但我不能使它工作几个小时:
<Style x:Key="NewContentStyle" TargetType="ContentPresenter">
<Setter Property="OpacityMask">
<Setter.Value>
<LinearGradientBrush x:Name="FillGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0.5"/>
<GradientStop Color="Transparent" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
<Storyboard x:Key="NewContentStoryboard">
<PointAnimation Storyboard.TargetProperty="StartPoint" Storyboard.TargetName="FillGradient" From="0.5 0" To="0 0.5" Duration="00:00:1" />
<PointAnimation Storyboard.TargetProperty="EndPoint" Storyboard.TargetName="FillGradient" From="1 0.5" To="0 0.5" Duration="00:00:1"/>
</Storyboard>
我得到一个错误"'FillGradient'的名字不能在'System.Windows.Controls.ContentPresenter'的名字范围中找到。"
请试试:
<Storyboard x:Key="NewContentStoryboard">
<PointAnimation Storyboard.TargetProperty="OpacityMask.(LinearGradientBrush.StartPoint)" From="0.5 0" To="0 0.5" Duration="00:00:1" />
<PointAnimation Storyboard.TargetProperty="OpacityMask.(LinearGradientBrush.EndPoint)" From="1 0.5" To="0 0.5" Duration="00:00:1"/>
</Storyboard>