淡出淡出的TextBlock(WFP,VB) [英] Fade-out Fade-in for a TextBlock (WFP, VB)

查看:122
本文介绍了淡出淡出的TextBlock(WFP,VB)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我有一个TextBlock,并且想要每5秒更改一次它的Text属性.一切正常,但我想为文本添加淡入淡出效果.
旧文本淡出,新文本淡入.
有人可以帮我吗?

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?

推荐答案

您可以使用几个情节提要.在计时器中调度情节提要,更改测试,然后运行下一个情节提要.
You could use a couple of storyboards. In a timer dispatch the storyboard, change the test and then run the next storyboard.
<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>


这篇关于淡出淡出的TextBlock(WFP,VB)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆