BindableObject.BindingContextProperty 字段

定义

实现其接口由 BindingContext 属性提供的绑定属性。

public static readonly Xamarin.Forms.BindableProperty BindingContextProperty;
 staticval mutable BindingContextProperty : Xamarin.Forms.BindableProperty

字段值

注解

以下示例演示如何设置 BindingContext 的绑定:

class PersonView : ContentView 
{
  public PersonView ()
  {
    var label = new Label ();
    label.SetBinding (Label.TextProperty, "Name");
    Content = label;
  }
}

var stack = new StackLayout {
  Orientation = StackOrientation.Vertical,  
};

var jane = new PersonView ();
jane.SetBinding (BindableObject.BindingContext, "Jane");
stack.Children.Add (jane);

var john = new PersonView ();
john.SetBinding (BindableObject.BindingContext, "John");
stack.Children.Add (john);

stack.BindingContext = new {Jane = new {Name = "Jane Doe"}, John = new {Name = "John Doe"}};

适用于