Search code examples
mvvmdata-bindingxamarinxamarin.forms

Xamarin.Forms MVVM - Is there a way to Unset a Binding?


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?


Solution

  • 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);