我有RibbonButton
使用StaticResource
背景画笔的元素。
现在我正在尝试将动画应用于此按钮的背景颜色,但发生的情况是所有使用相同的元素StaticResource
的背景颜色也都动画了!!!
如何使此动画仅适用于RibbonButton
?
<Ribbon>
<RibbonTab Header="Ribbon Tab 1">
<RibbonGroup Header="Ribbon Group 1" Background="{StaticResource BackgroundBrush}">
<RibbonButton x:Name="RibbonButton1" Label="Ribbon Button 1"
VerticalAlignment="Bottom"
Style="{DynamicResource RibbonButton1_RibbonButtonStyle}"
Background="{StaticResource BackgroundBrush}">
<RibbonButton.Resources>
<Style x:Key="RibbonButton1_RibbonButtonStyle"
TargetType="RibbonButton">
<Style.Triggers>
<DataTrigger Binding="{Binding SomethingChanged}" Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.(SolidColorBrush.Color)"
Duration="0:0:0.1" To="Gold" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard FillBehavior="Stop">
<ColorAnimation Storyboard.TargetProperty="Background.(SolidColorBrush.Color)"
Duration="0:0:0.1" To="{StaticResource BackgroundColor}" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</RibbonButton.Resources>
</RibbonButton>
</RibbonGroup>
....
</RibbonTab>
</Ribbon>