change foreground color of label in an animation RRS feed

  • Question

  • 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.
    Saturday, February 21, 2009 6:02 PM

All replies

  • 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....

          <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 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"/>  

    label named as label
    <Label Margin="162,0,274,99" VerticalAlignment="Bottom" Height="39" Content="Label" x:Name="label"/> 

    how to use storyboard and timeline plese see my article http://www.codeproject.com/KB/WPF/WITIYMIWYG.aspx

     I hope this will help you :)
    Prasad - www.beautifulmind.blog.co.in
    • Proposed as answer by prasad22 Monday, February 23, 2009 4:46 AM
    Monday, February 23, 2009 4:46 AM