Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to animate the font weight of a label in WPF?

Tags:

.net

wpf

I'm having trouble finding an animation storyboard type that allows me to animate the FontWeight property of a label from "Normal" to "Bold". Does anyone have any experience with this?

like image 900
Daniel Avatar asked Jul 21 '10 20:07

Daniel


1 Answers

Suppose initial your FontWeight of a label is Normal, like the below :

<Label x:Name="label" Content="Label" HorizontalAlignment="Left" FontWeight="Normal" VerticalAlignment="Top"/>

You can have the below storyboard to make the FontWeight of a label to Bold :

<Storyboard>
     <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.FontWeight)" Storyboard.TargetName="label">
        <DiscreteObjectKeyFrame KeyTime="0">
            <DiscreteObjectKeyFrame.Value>
                <FontWeight>Bold</FontWeight>
            </DiscreteObjectKeyFrame.Value>
        </DiscreteObjectKeyFrame>
    </ObjectAnimationUsingKeyFrames>
</Storyboard>
like image 171
Malcolm Avatar answered Sep 28 '22 06:09

Malcolm