简体   繁体   中英

WPF begin fontsize animation of a textblock from C#

I would like to start a fontsize animation of a textblock from C# code. How can I do this?

I want increase/decrease fontsize during a period of 1 second.

Thanks!

DoubleAnimation animation = new DoubleAnimation(20, TimeSpan.FromSeconds(1.0));
MyTextBlock.BeginAnimation(TextBlock.FontSizeProperty, animation);

Where MyTextBlock is the instance of the TextBlock you wish to animate, and 20 is the target fontsize.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM