我正在尝试为我的 TabItem 的背景/渐变设置动画。但是,我收到一个错误:
附加信息:无法解析属性路径“Background.GradientStops[2].Color”中的所有属性引用。验证适用的对象是否支持这些属性。
当我将鼠标悬停在选项卡项上时会发生错误。
这是 XAML:
<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid>
<Border Name="Border" BorderBrush="#666" BorderThickness="1,1,1,0" CornerRadius="8,8,0,0" Margin="-2,0,3,-1">
<!-- Some irrelevant code here -->
</Border>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation Duration="0:0:0.3" To="#EBEBEB" Storyboard.TargetProperty="Background.GradientStops[1].Color" Storyboard.TargetName="Border"/>
<ColorAnimation Duration="0:0:0.3" To="#CDCDCD" Storyboard.TargetProperty="Background.GradientStops[2].Color" Storyboard.TargetName="Border"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#fff" Offset="0.35"></GradientStop>
<GradientStop Color="#e9e9e9" Offset="0.75"></GradientStop>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Border" Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0.35">
<GradientStop.Color>
<Color A="127" R="255" G="255" B="255" />
</GradientStop.Color>
</GradientStop>
<GradientStop Offset="0.75">
<GradientStop.Color>
<Color A="127" R="233" G="233" B="233" />
</GradientStop.Color>
</GradientStop>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
我认为Storyboard.TargetProperty
是错误的。应该是什么?