文本框文本颜色动画 [英] Textbox Text-Color Animation

查看:189
本文介绍了文本框文本颜色动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能进行动画文本/标签的价值只是一部分。例如,txt1.text =这是一个样;那么我想如果你明白我的意思的动画字样本,以改变其颜色/透明度等。如果有可能,请证明code谢谢!

Is it possible to animate just the part of the value of textbox/label. For example, txt1.text = "This is a Sample";. then I want to animate the word "Sample" to change its color/opacity etc. If you get what i mean. If it is possible please demonstrate the code Thanks!

推荐答案

我觉得你不能用作为其文本没有格式选项一个TextBox做到这一点。不知道,如果标签允许,但文本块可能会帮助您:

I think you can't do it with a TextBox as its text has no formatting options. Not sure if the Label allows it, but the TextBlock might help you:

<TextBlock>
  <TextBlock.Triggers>
    <EventTrigger RoutedEvent="Loaded">
      <BeginStoryboard>
        <Storyboard>
          <ColorAnimation Storyboard.TargetName="scb01"
                          Storyboard.TargetProperty="Color"
                          From="White"
                          To="Black"
                          Duration="0:0:0.5"
                          AutoReverse="True"
                          RepeatBehavior="Forever" />
        </Storyboard>
      </BeginStoryboard>
    </EventTrigger>
  </TextBlock.Triggers>
  One <Run>
    <Run.Foreground>
      <SolidColorBrush x:Name="scb01"
                        Color="Red" />
    </Run.Foreground>
    Two</Run> Three
</TextBlock>

这篇关于文本框文本颜色动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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