How to show a comma separated number with StringFormat in XAML?

女生的网名这么多〃 提交于 2019-12-10 12:49:46

问题


My code currently shows like this: 43521 reviews, I want it be like this: 43,521 reviews. How can I do that? and is there a full reference for all possible formats in StringFormat? couldn't find anything. thanks.

<TextBlock Text="{Binding Reviews,StringFormat='{}{0} reviews'}"/>

回答1:


just change your string format like this:

<TextBlock Text="{Binding Reviews,StringFormat='{}{0:0,0} reviews'}"/>



回答2:


This one also worked :)

<TextBlock Text="{Binding Reviews,StringFormat='{}{0:N0} reviews'}"/>



回答3:


Try this:

<TextBlock Text="{Binding Reviews,StringFormat='{}{0:#,0} reviews'}"/>



回答4:


This is what i use for showing comma with 2 decimal precision

<Label Content="{Binding Reviews}" ContentStringFormat="{0:N2} reviews" />


来源:https://stackoverflow.com/questions/22296001/how-to-show-a-comma-separated-number-with-stringformat-in-xaml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!