【问题标题】:How to display a comma value on label - xamarin如何在标签上显示逗号值 - xamarin
【发布时间】:2022-01-22 17:05:06
【问题描述】:

我有:

<Label Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding Price, StringFormat='{0:F0} $'}" XAlign="Center" YAlign="Center" TextColor="#2bff00" FontAttributes="Bold" FontSize="Small" HorizontalOptions="CenterAndExpand"/>

但是我的对象属性是:

JsonProperty("price_usd")]
public decimal? Price { get; set; }

所以真正的价值是:"price_usd":"3824.56" 和我的标签显示 3824 没有逗号?

【问题讨论】:

标签: c# xamarin


【解决方案1】:

查看文档中的numeric format strings。另外,这里有一些简单的例子:

String.Format("{0:0.##}", 123.4567);      // "123.46"
String.Format("{0:0.##}", 123.4);         // "123.4"
String.Format("{0:0.##}", 123.0);         // "123"

您可以在 .xaml 中使用这些格式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-25
    • 1970-01-01
    • 2010-11-16
    • 1970-01-01
    • 1970-01-01
    • 2021-06-11
    • 1970-01-01
    相关资源
    最近更新 更多