Share via


BindableObject.BindingContext 属性

定义

获取或设置一个 对象,该对象包含属于此 BindableObject的绑定属性的目标属性。 这是一种可绑定属性。

public:
 property System::Object ^ BindingContext { System::Object ^ get(); void set(System::Object ^ value); };
public object BindingContext { get; set; }
member this.BindingContext : obj with get, set
Public Property BindingContext As Object

属性值

一个 Object ,它包含属于此 BindableObject的绑定属性所面向的属性。 这是一种可绑定属性。

注解

通常,如果在 BindingContext 进行所有调用 SetBinding(BindableProperty, BindingBase) 后设置 ,则运行时性能会更好。

以下示例演示如何将 BindingContext 和 Binding 应用到从 BindableObject) 继承的 Label (:

var label = new Label ();
label.SetBinding (Label.TextProperty, "Name");
label.BindingContext = new {
    Name = "John Doe",
    Company = "Xamarin"
};

Debug.WriteLine (label.Text); // prints "John Doe"

适用于