See Also: BindableProperty Members
The following example shows the creation of a BindableProperty as a backing store for a property. It shows also how to bind to that BindableProperty.
C# Example
public class MockBindable : BindableObject
{
public static readonly BindableProperty FooProperty =
BindableProperty.Create<MockBindable, string> (w => w.Foo, default(string));
public string Foo {
get { return (string)GetValue (FooProperty); }
set { SetValue (FooProperty, value); }
}
}
public class MockViewModel
{
public string Name {get;set;}
}
MockViewModel model = new MockViewModel { Name = "John Doe" };
var bindable = new MockBindable ();
bindable.SetBinding (MockBindable.FooProperty, "Name");
bindable.BindingContext = model;
Console.WriteLine (bindable.Foo); //prints "John Doe"