BindableObject.BindingContextProperty 字段
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
实现其接口由 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"}};