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

Ian*_*ink 2 c# visual-studio ios 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;
    }
Run Code Online (Sandbox Code Playgroud)

Pet*_*ete 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;
    }
Run Code Online (Sandbox Code Playgroud)