【发布时间】:2015-08-08 09:42:22
【问题描述】:
我的模型视图:
public string Status {
get { return _status; }
set {
if (value == _status) {
return;
}
_status = value;
OnPropertyChanged ("Status");
}
我的观点:
Label labelStatus = new Label {
TextColor = Color.Green,
FontSize = 20d
};
labelStatus.SetBinding (Label.TextProperty, "Status");
然后我想使用类似的方式来呈现状态:
string presentStatus = string.Format("Your status is {0}...", labelStatus);
Label yourStatus = new Label{Text=presentStatus}
但这并没有真正起作用。也不用
string presentStatus = string.Format("Your status is {0}...", SetBinding(Label.TextProperty,"Status"));
那么在将绑定值呈现给视图中之前,我应该如何使用更多文本添加绑定值。
如果使用 XAML(我没有),根据:http://developer.xamarin.com/guides/cross-platform/xamarin-forms/xaml-for-xamarin-forms/data_binding_basics/ 似乎是可能的
【问题讨论】:
-
你在任何地方设置 BindingContext 吗?
-
是的,仅显示 labelstatus 就可以了,但是当我尝试在其周围添加文本时,它会失败。
标签: binding xamarin.forms