BindableObject.SetValue メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
オーバーロード
SetValue(BindableProperty, Object) |
指定したプロパティの値を設定します。 |
SetValue(BindablePropertyKey, Object) |
propertyKey の値を設定します。 |
SetValue(BindableProperty, Object)
指定したプロパティの値を設定します。
public void SetValue (Xamarin.Forms.BindableProperty property, object value);
member this.SetValue : Xamarin.Forms.BindableProperty * obj -> unit
パラメーター
- property
- BindableProperty
値を割り当てる BindableProperty。
- value
- Object
設定する値。
注釈
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); }
}
}
適用対象
SetValue(BindablePropertyKey, Object)
propertyKey の値を設定します。
public void SetValue (Xamarin.Forms.BindablePropertyKey propertyKey, object value);
member this.SetValue : Xamarin.Forms.BindablePropertyKey * obj -> unit
パラメーター
- propertyKey
- BindablePropertyKey
値を割り当てる BindablePropertyKey。
- value
- Object
設定する値。
注釈
この メソッドと BindablePropertyKey は、書き込みアクセスが制限された BindableProperties を実装するのに役立ちます。 書き込みアクセスは BindablePropertyKey のスコープに制限されます。
次の例は、"内部" 書き込みアクセス権を持つ BindableProperty を宣言する方法を示しています。
class MyBindable : BindableObject
{
internal static readonly BindablePropertyKey MyPropertyKey =
BindableProperty.CreateReadOnly<MyBindable, string> (w => w.My, default(string));
public static readonly BindableProperty MyProperty = MyPropertyKey.BindableProperty;
public string My {
get { return (string)GetValue (MyProperty); }
internal set { SetValue (MyPropertyKey, value); }
}
}