2014-11-13 48 views
2

我有一个自定义FiancialCell工作,但不格式化为货币。是否有另一种方法来更改绑定格式,以便它是$?Xamarin表单自定义单元货币格式?

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; 
    } 

回答

5

改为使用"{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; 
    } 
+0

工作得非常好,谢谢! – meanbunny