我有一个可行的自定义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;
}
答案 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;
}