Reputation: 5585
Is there a way to programmatically unset a binding? Something like:
myLabel.UnsetBinding(Label.TextColorProperty);
Surely there's gotta be a way to do this?
Upvotes: 5
Views: 2436
Reputation: 783
A Binding is attached to a BindableProperty, not a class.
You can just set the Property to anything else and the Binding will be gone;
myLabel.Text = String.Empty;
Note: The above (Keith's) is the correct answer.
Upvotes: 4
Reputation: 3228
You are looking for the RemoveBinding()
method: https://developer.xamarin.com/api/member/Xamarin.Forms.BindableObject.RemoveBinding/p/Xamarin.Forms.BindableProperty/
For your example:
myLabel.RemoveBinding(Label.TextColorProperty);
Upvotes: 12