I have the following TextBlock
with animation
<TextBlock Text="{Binding StatusMessage}"
Margin="5,0,0,0"
Foreground="White">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding IsSystemReady,
NotifyOnSourceUpdated=True,
Mode=OneWay}"
Value="False">
<DataTrigger.EnterActions>
<BeginStoryboard Name="FadeOut">
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity"
From="1.0"
To="0.0"
Duration="0:0:3.5"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
<DataTrigger Binding="{Binding IsSystemReady,
NotifyOnSourceUpdated=True,
Mode=OneWay}"
Value="True">
<DataTrigger.EnterActions>
<StopStoryboard BeginStoryboardName="FadeOut" />
</DataTrigger.EnterActions>
<Setter Property="Opacity" Value="1.0"/>
</DataTrigger>
<Trigger Property="Opacity" Value="0.0">
<Setter Property="Text" Value="Ready"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
The animation works, but when it is finished (i.e. the Opacity of the control is 0.0) I want to return automatically to the ready state after a status message has been shown and elegantly faded away. I am attempting to do this with a standard Trigger
but this is not firing, why and how do I fix this?
Thanks for your time.
The Trigger
is not firing because Opacity
property is still locked by the animation, but you can use an animation to change the Text
value if you want using a ObjectAnimation
.
Example:
<BeginStoryboard Name="FadeOut">
<Storyboard >
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="1.0" To="0.0" Duration="0:0:3.5"/>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Text" BeginTime="0:0:3.5" >
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Ready" />
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="1.0" To="1.0" BeginTime="0:0:3.5"/>
</Storyboard>
</BeginStoryboard>
However setting the Text
to Ready
in the Animation will not set the StatusMessage
property to Ready
.