What I need to do:
At the time of the event
GotFocus
, no event ofMouseEnter
andMouseLeave
run.After the events
LostFocus
,MouseEnter
andMouseLeave
become active again.
Given the needs, I've written the following code, but the commands for Pause
and Resume
do not work.
<ControlTemplate x:Key="SpecialNumber" TargetType="{x:Type TextBox}">
<Grid>
<Image x:Name="SpecialBg" Style="{DynamicResource CallStatusSpecialBg}"/>
<Image x:Name="SpecialIBeam" Style="{DynamicResource CallStatusSpecialIBeam}" Source="../image/I-beam-b.png"/>
<TextBox x:Name="SpecialText" Style="{DynamicResource CallStatusSpecialNumberText}" Text="5555" />
</Grid>
<ControlTemplate.Resources>
<Storyboard x:Key="Hide">
<DoubleAnimation Storyboard.TargetName="SpecialBg" Storyboard.TargetProperty="Opacity" Duration="0:0:0.4" To="0" />
<DoubleAnimation Storyboard.TargetName="SpecialIBeam" Storyboard.TargetProperty="Opacity" Duration="0:0:0.2" To="0" />
<DoubleAnimation Storyboard.TargetName="SpecialText" Storyboard.TargetProperty="Opacity" Duration="0:0:0.2" To="0" />
</Storyboard>
<Storyboard x:Key="ShowHalf">
<DoubleAnimation Storyboard.TargetName="SpecialBg" Storyboard.TargetProperty="Opacity" Duration="0:0:0.2" To="1" />
<DoubleAnimation Storyboard.TargetName="SpecialIBeam" Storyboard.TargetProperty="Opacity" Duration="0:0:0.4" To="1" />
<DoubleAnimation Storyboard.TargetName="SpecialText" Storyboard.TargetProperty="Opacity" Duration="0:0:0.2" To="0.01" />
</Storyboard>
<Storyboard x:Key="Show">
<DoubleAnimation Storyboard.TargetName="SpecialBg" Storyboard.TargetProperty="Opacity" Duration="0:0:0.2" To="1" />
<DoubleAnimation Storyboard.TargetName="SpecialIBeam" Storyboard.TargetProperty="Opacity" Duration="0:0:0.4" To="1" />
<DoubleAnimation Storyboard.TargetName="SpecialText" Storyboard.TargetProperty="Opacity" Duration="0:0:0.2" To="1" />
</Storyboard>
</ControlTemplate.Resources>
<ControlTemplate.Triggers>
<EventTrigger SourceName="SpecialText" RoutedEvent="UIElement.MouseEnter" >
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource ShowHalf}" x:Name="SpecialTextMouseEnter"/>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger SourceName="SpecialText" RoutedEvent="UIElement.MouseLeave" >
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource Hide}" x:Name="SpecialTextMouseLeave"/>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger SourceName="SpecialText" RoutedEvent="UIElement.GotFocus" >
<EventTrigger.Actions>
<PauseStoryboard BeginStoryboardName="SpecialTextMouseLeave" />
<PauseStoryboard BeginStoryboardName="SpecialTextMouseEnter" />
<BeginStoryboard Storyboard="{StaticResource Show}" x:Name="SpecialTextGotFocus"/>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger SourceName="SpecialText" RoutedEvent="UIElement.LostFocus" >
<EventTrigger.Actions>
<ResumeStoryboard BeginStoryboardName="SpecialTextMouseLeave" />
<ResumeStoryboard BeginStoryboardName="SpecialTextMouseEnter" />
<BeginStoryboard Storyboard="{StaticResource Hide}" x:Name="SpecialTextLostFocus"/>
</EventTrigger.Actions>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>