因为样式不是像OO继承那样继承的,所以嵌套样式在其范围内找不到故事板。
完成突出显示的最简单方法是添加第二个故事板,它反转突出显示。
<Storyboard x:Key="startHighlight" >
<DoubleAnimation
Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)"
To="8"
Duration="0:0:0.5" />
</Storyboard>
<Storyboard x:Key="reverseHighlight" >
<DoubleAnimation
Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)"
To="0"
Duration="0:0:0.2" />
</Storyboard>
<Style TargetType="{x:Type FrameworkElement}">
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect Color="Red"
BlurRadius="0"
ShadowDepth="0" />
</Setter.Value>
</Setter>
<Style.Triggers>
<EventTrigger RoutedEvent="UIElement.GotFocus">
<BeginStoryboard Storyboard="{StaticResource startHighlight}">
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="UIElement.LostFocus">
<BeginStoryboard Storyboard="{StaticResource reverseHighlight}">
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource {x:Type FrameworkElement}}" TargetType="{x:Type TextBox}">
</Style>