BindableObject.GetValue(BindableProperty) 메서드

정의

BindableProperty에 포함되는 값을 반환합니다.

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

매개 변수

property
BindableProperty

값을 가져올 BindableProperty입니다.

반환

System.Object

BindableProperty에 포함되는 값입니다.

설명

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

적용 대상