将文本合并到String.Format

时间:2015-07-13 11:14:13

标签: wpf xaml string-formatting

我有StringFormat StringFormat={}{0:#,0}}代表十进制数字,我希望在此数字后添加我自己的文字。

这是我尝试过的(但它不能用StringFormat内的文本进行编译)

Content="{Binding Path=(my:MyClass.MyStaticProperty),StringFormat={}{0:#,0}} My Text"

my:MyClass.MyStaticProperty is integer type.

1 个答案:

答案 0 :(得分:0)

使用Label时,无法使用StringFormat格式化内容。请查看this主题。

您的解决方案是使用ContentStringFormat

<Label Content="{Binding Source={x:Static my:MyClass.MyStaticProperty}}"
       ContentStringFormat="{}{0:#.0} My Text"/>
相关问题