BindableObject.GetValue(BindableProperty) メソッド

定義

BindableProperty に含まれる値を返します。

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

パラメーター

property
BindableProperty

値の取得先の BindableProperty。

戻り値

BindableProperty に含まれる値。

注釈

GetValue(BindableProperty)および SetValue は、によって実装されるプロパティの値にアクセスするために使用され BindableProperty ます。 つまり、通常、アプリケーション開発者は、アクセサーがの結果GetValue(BindableProperty)public適切な型にキャストして返し、アクセサーがを使用SetValueして正しいプロパティに値を設定するプロパティgetを定義することで、setバインドされたプロパティのインターフェイスを提供します。 アプリケーション開発者は、バインドされたプロパティのインターフェイスを定義するパブリック プロパティで他の手順を実行しないでください。

次の例は、実行時にバインドが行われるときにターゲット プロパティで提供される実装のバインド可能なプロパティ インターフェイスを作成する方法を示しています。

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

適用対象