<Window.Resources>
<Storyboard x:Key="ButtonEffect_01" AutoReverse="True" RepeatBehavior="Forever">
<ColorAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)"
Storyboard.TargetName="btnAdd">
<EasingColorKeyFrame KeyTime="0" Value="Black"/>
<EasingColorKeyFrame KeyTime="0:0:0.4" Value="#FFF3FF00"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Button x:Name="btnAdd" Content="Add" Width="69" Height="27">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<ei:ControlStoryboardAction Storyboard="{StaticResource ButtonEffect_01}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
我有3个更多按钮btnDelete,btnUpdate,btnBack我可以为所有这些按钮使用相同的Storyboard吗?任何绑定方法?
答案 0 :(得分:2)
您可以将动画分享给多个对象,但需要检查动画状态。 为防止错误,您可以在分配新目标之前停止动画:
private void MouseEnter(object sender, PointerRoutedEventArgs e)
{
ButtonEffect_01.Stop();
ButtonEffect_01.SetValue(Storyboard.TargetNameProperty, (sender as Button).Name);
ButtonEffect_01.Begin();
}
来源:http://msdn.microsoft.com/en-us/library/windows/apps/dn376886.aspx
答案 1 :(得分:1)
为避免指定目标,您可以在Style
的{{1}}内定义故事板:
Button