Xamarin形成自定义单元格货币格式?

时间:2014-11-13 23:40:56

标签: c# ios visual-studio xamarin xamarin.forms

我有一个可行的自定义FiancialCell,但不会格式化为货币。是否有另一种方法来更改绑定格式,以便它是$?

    public FinancialCell()
    {
          .......

        //Set the bindings to the FinancialRow object to be bound to this
        lblTitle.SetBinding(Label.TextProperty, "Title");

        ///Why does this not format to $ when displayed?
        lblValue.SetBinding(Label.TextProperty, "Value", stringFormat: "C");


        this.View = stack;
    }

1 个答案:

答案 0 :(得分:6)

使用"{0:C}"代替它,它将起作用。

以下是与修复集成的示例,仅为了完整性: -

    public FinancialCell()
    {
          .......

        //Set the bindings to the FinancialRow object to be bound to this
        lblTitle.SetBinding(Label.TextProperty, "Title");

        ///Why does this not format to $ when displayed?
        lblValue.SetBinding(Label.TextProperty, "Value", stringFormat: "{0:C}");


        this.View = stack;
    }