我在Xamarin.Forms中的代码中使用了一个Label
,如下所示:
var label = new Label();
label.SetBinding(Label.TextProperty, new Binding("Time", stringFormat: "{}{0:hh\\:mm}", mode: BindingMode.TwoWay, source: this));
但是这会返回错误:
但是这在 Xaml 中可行:System.FormatException: 输入的字符串格式不正确。
<Label Text="{Binding StartTime, StringFormat='{}{0:hh\\:mm}'}}"/>
我该如何在Xamarin.Forms中对
TimeSpan
类型的绑定使用字符串格式化?
{}
,因为这些是特定于XAML的。 - Zein Makki{}
XAML 转义字符串吗? - Zein Makki