更改动画中标签的前景色 [英] change foreground color of label in an animation

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

问题描述

如何在动画期间更改标签的前景色?我正在使用标签,我在鼠标进入,离开和关闭状态期间动画它们,我试图让标签的颜色在发生时改变。谢谢。

解决方案



在StoryBoard时间轴的对象和时间线面板中,您需要在秒时添加记录关键帧改变颜色并改变标签的颜色。这里是xaml生成的例子....








< td> < Window.Resources >





























< 故事板x: = < font style ="color:blue">" Storyboard1" >
< ColorAnimationUsingKeyFrames BeginTime = " 00:00:00" Storyboard.TargetName = " label" Storyboard.TargetProperty = "(Panel.Background)。(SolidColorBrush.Color)" >
< SplineColorKeyFrame KeyTime = " 00:00:01" Value = "#00D12121" />
< SplineColorKeyFrame KeyTime = " 00:00:03" = "#00D12121" />
< / ColorAnimationUsingKeyFrames >
< ColorAnimationUsingKeyFrames BeginTime = " 00:00:00" Storyboard.TargetName = " label" Storyboard.TargetProperty = "( TextElement.Foreground)。(SolidColorBrush.Color)" >
< SplineColorKeyFrame KeyTime = " 00:00:01" Value = "#FFE33333" />
< SplineColorKeyFrame KeyTime = " 00:00:03" = " #FFFD0000" />
< SplineColorKeyFrame KeyTime = " 00:00:04" = "#FF000000" />
< / ColorAnimationUsingKeyFrames >
< / < font style ="font-size:11px"> Storyboard >
< / Window.Resources >

how do you change the foreground color of a label during an animation?  i'm using labels and i'm animating them during a mouse enter, leave, and down states and i'm trying to get the label's color to change when these happen.  thanks.

解决方案



In the Objects and Timeline Panel in the StoryBoard Timeline you have to add record key frame on the seconds when do you want to change the color and change the color of the lable.
here is the xaml generated example....

    <Window.Resources> 
      <Storyboard x:Key="Storyboard1">  
        <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="label" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">  
            <SplineColorKeyFrame KeyTime="00:00:01" Value="#00D12121"/>  
            <SplineColorKeyFrame KeyTime="00:00:03" Value="#00D12121"/>  
        </ColorAnimationUsingKeyFrames> 
        <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="label" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)">  
            <SplineColorKeyFrame KeyTime="00:00:01" Value="#FFE33333"/>  
            <SplineColorKeyFrame KeyTime="00:00:03" Value="#FFFD0000"/>  
            <SplineColorKeyFrame KeyTime="00:00:04" Value="#FF000000"/>  
        </ColorAnimationUsingKeyFrames> 
      </Storyboard> 
    </Window.Resources> 


这篇关于更改动画中标签的前景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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