wpf 绑定字符串格式数字逗号和无小数位

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18759229/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 09:37:58  来源:igfitidea点击:

Binding String Format Number Commas & No Decimal Places

wpfvisual-studiodata-bindingstring-formatting

提问by I am Bish

Okay this is an easy one but I'd hugely appreciate your help because I've been mucking around for an hour trying to get it to work.

好的,这是一个简单的方法,但我非常感谢您的帮助,因为我已经折腾了一个小时试图让它工作。

How do I change the following to get rid of the decimal places and just show the whole number?

如何更改以下内容以去除小数位并仅显示整数?

Binding="{Binding ANLA, StringFormat=n}"

I know the format is something like

我知道格式是这样的

{0:0,0}

But I can't get the backslashes to work.

但我无法让反斜杠工作。

Thanks hugely in advance!

非常感谢!

回答by Sheridan

You almosthad it... how about trying this:

几乎拥有它......试试这个怎么样:

{Binding ANLA, StringFormat='0,0.'}

Please note that this willround the number to the nearest integer.

请注意,这会将数字四舍五入到最接近的整数。