如何在 XAML 中使用 StringFormat 显示逗号​​分隔的数字? [英] How to show a comma separated number with StringFormat in XAML?

查看:39
本文介绍了如何在 XAML 中使用 StringFormat 显示逗号​​分隔的数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码目前显示如下:43521 评论,我希望它是这样的:43,521 评论.我怎样才能做到这一点?是否有 StringFormat 中所有可能格式的完整参考?找不到任何东西.谢谢.

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'}"/>

推荐答案

只需像这样更改您的字符串格式:

just change your string format like this:

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

这篇关于如何在 XAML 中使用 StringFormat 显示逗号​​分隔的数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆