Xamarin.Forms.BindableObjectExtensions.SetBinding Method
Creates and applies a binding to a property.

Syntax

public static void SetBinding (this BindableObject self, BindableProperty targetProperty, string path, BindingMode mode, IValueConverter converter, string stringFormat)

Parameters

self
The Xamarin.Forms.BindableObject.
targetProperty
The BindableProperty on which to set a bindinge.
path
A string indicating the property path to bind to.
mode
The Xamarin.Forms.BindingMode for the binding. This parameter is optional. Default is BindingMode.Default.
converter
An Xamarin.Forms.IValueConverter for the binding. This parameter is optional. Default is null.
stringFormat
A string used as stringFormat for the binding. This parameter is optional. Default is null.

Remarks

The following example shows how to use the extension method to set a binding.

C# Example

var label = new Label ();
label.SetBinding (Label.TextProperty, "Name");
label.BindingContext = new {Name = "John Doe", Company = "Xamarin"};
Debug.WriteLine (label.Text); //prints "John Doe"
      

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.2.0.0, 1.3.0.0