How can I animate Label.Content with a DoubleAnimation?

时间:2015-09-01 22:14:31

标签: wpf animation wpf-animation doubleanimation

A DoubleAnimation changes a double value over time. I would like to set the Content property of a Label to this value. However, this fails because WPF does not convert the double to a string.

Do I have to subclass the Label and add a new double propery, which is bound to the Content, and let the DoubleAnimation change this new property? Or is there an easier way?

The double value in question is not limited to certain values, i.e. fixed StringKeyframes cannot be used.

Example use case: A countdown timer with extended precision, which displays the remaining time in a Label.

1 个答案:

答案 0 :(得分:1)

设置标签ContentStringFormat="{}{0}",或使用TextBox并在文本绑定中设置StringFormat

相关问题