我为选项卡控件制作了一个模板。它的作用是获取边框的背景并在鼠标悬停时进行动画处理。
当鼠标离开时,它应该从 Background 属性中读取当前值并相应地设置它们。
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="false"/>
<Condition Property="IsMouseOver" Value="true"/>
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="Bd"
Storyboard.TargetProperty="Background.GradientStops[0].Color" To="#003372"
Duration="0:0:0.2"/>
<ColorAnimation Storyboard.TargetName="Bd"
Storyboard.TargetProperty="Background.GradientStops[1].Color" To="#025092"
Duration="0:0:0.2"/>
<ColorAnimation Storyboard.TargetName="Bd"
Storyboard.TargetProperty="Background.GradientStops[2].Color" To="#003372"
Duration="0:0:0.2"/>
</Storyboard>
</BeginStoryboard>
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="Bd"
Storyboard.TargetProperty="Background.GradientStops[0].Color" To="{TemplateBinding Background.GradientStops[0].Color}"
Duration="0:0:0.2"/>
<ColorAnimation Storyboard.TargetName="Bd"
Storyboard.TargetProperty="Background.GradientStops[1].Color" To="{TemplateBinding Background.GradientStops[1].Color}"
Duration="0:0:0.2"/>
<ColorAnimation Storyboard.TargetName="Bd"
Storyboard.TargetProperty="Background.GradientStops[2].Color" To="{TemplateBinding Background.GradientStops[2].Color}"
Duration="0:0:0.2"/>
</Storyboard>
</BeginStoryboard>
</MultiTrigger.ExitActions>
</MultiTrigger>
问题是
To="{TemplateBinding Background.GradientStops[0].Color}"
部分不工作。我应该在那里写什么?