BindableObject.SetBinding(BindableProperty, BindingBase) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Assigns a binding to a property.
public void SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding);
member this.SetBinding : Xamarin.Forms.BindableProperty * Xamarin.Forms.BindingBase -> unit
Parameters
- targetProperty
- BindableProperty
The BindableProperty on which to set a binding.
- binding
- BindingBase
The binding to set.
Remarks
The following example shows how to set a binding to a property:
var label = new Label ();
label.SetBinding (Label.TextProperty, new Binding ("Name"));
label.BindingContext = new {
Name = "John Doe",
Company = "Xamarin"
};
Debug.WriteLine (label.Text); // prints "John Doe"