我试图为我的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
是错误的。它应该是什么?
答案 0 :(得分:1)
那可能不是零基指数吗?
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.GradientStops[0].Color" .../>
<ColorAnimation Storyboard.TargetProperty="Background.GradientStops[1].Color" .../>
</Storyboard>