Click here to Skip to main content
15,888,053 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a TextBlock and want to change it's Text property every 5 seconds, for example. Everything's OK but I want to add fade effects for text.
The old text fades out, the new one fades in.
Can someone help me?
Posted

1 solution

You could use a couple of storyboards. In a timer dispatch the storyboard, change the test and then run the next storyboard.
XML
<Storyboard x:Key="Storyboard1" x:Name="sb1">
    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="textBox1">
        <EasingColorKeyFrame KeyTime="0:0:0.5" Value="White"/>
    </ColorAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="Storyboard2" x:Name="sb2">
    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="textBox1">
        <EasingColorKeyFrame KeyTime="0" Value="White"/>
        <EasingColorKeyFrame KeyTime="0:0:0.5" Value="Black"/>
    </ColorAnimationUsingKeyFrames>
</Storyboard>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900