BindableObject.GetValue(BindableProperty) BindableObject.GetValue(BindableProperty) Method

Definition

Returns the value that is contained the BindableProperty.

public object GetValue (Xamarin.Forms.BindableProperty property);
member this.GetValue : Xamarin.Forms.BindableProperty -> obj
Parameters
property
BindableProperty BindableProperty

The BindableProperty for which to get the value.

Returns

The value that is contained the BindableProperty.

Remarks

GetValue(BindableProperty) and SetValue are used to access the values of properties that are implemented by a BindableProperty. That is, application developers typically provide an interface for a bound property by defining public property whose get accessor casts the result of GetValue(BindableProperty) to the appropriate type and returns it, and whose set accessor uses SetValue to set the value on the correct property. Application developers should perform no other steps in the public property that defines the interface of the bound property.

The following example shows how to create a bindable property interface for an implementation that will be provided in the target property when the binding is made at run time.


class MyBindable : BindableObject
{
  public static readonly BindableProperty MyProperty = 
    BindableProperty.Create<MyBindable, string> (w => w.My, default(string));

  public string My {
    get { return (string)GetValue (MyProperty); }
    set { SetValue (MyProperty, value); } 
  }
}

Applies to