BindableObject.SetValue 메서드

정의

오버로드

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 . 즉, 애플리케이션 개발자는 일반적으로 속성을 정의하여 public 바인딩된 속성에 대한 인터페이스를 제공합니다. 해당 get 접근자가 의 결과를 GetValue(BindableProperty) 적절한 형식으로 캐스팅하고 반환하며, 접근 set 자가 를 사용하여 SetValue 올바른 속성의 값을 설정합니다. 애플리케이션 개발자는 바인딩된 속성의 인터페이스를 정의하는 public 속성에서 다른 단계를 수행해서는 안 됩니다.

다음 예제에서는 바인딩을 런타임에 만들 때 대상 속성에 제공 되는 구현에 대 한 바인딩 가능한 속성 인터페이스를 만드는 방법을 보여 집니다.

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의 scope 제한됩니다.

다음 예제에서는 "내부" 쓰기 액세스 권한이 있는 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); } 
  }
}

적용 대상