【发布时间】:2016-11-03 03:37:08
【问题描述】:
有没有办法以编程方式取消绑定?比如:
myLabel.UnsetBinding(Label.TextColorProperty);
肯定有办法做到这一点?
【问题讨论】:
标签: mvvm data-binding xamarin xamarin.forms
有没有办法以编程方式取消绑定?比如:
myLabel.UnsetBinding(Label.TextColorProperty);
肯定有办法做到这一点?
【问题讨论】:
标签: mvvm data-binding xamarin xamarin.forms
您正在寻找RemoveBinding() 方法:https://developer.xamarin.com/api/member/Xamarin.Forms.BindableObject.RemoveBinding/p/Xamarin.Forms.BindableProperty/
你的例子:
myLabel.RemoveBinding(Label.TextColorProperty);
【讨论】:
绑定附加到 BindableProperty,而不是类。
您可以将属性设置为其他任何值,绑定将消失;
myLabel.Text = String.Empty;
注意:以上(Keith's)是正确答案。
【讨论】: