Freigeben über


BindableObject.BindingContextProperty Feld

Definition

Bindbare Eigenschaft für BindingContext.

public: static initonly Microsoft::Maui::Controls::BindableProperty ^ BindingContextProperty;
public static readonly Microsoft.Maui.Controls.BindableProperty BindingContextProperty;
 staticval mutable BindingContextProperty : Microsoft.Maui.Controls.BindableProperty
Public Shared ReadOnly BindingContextProperty As BindableProperty 

Feldwert

Hinweise

In der Regel ist die Laufzeitleistung besser, wenn BindingContext festgelegt wird, SetBinding(BindableProperty, BindingBase) nachdem alle Aufrufe durchgeführt wurden.

Im folgenden Beispiel wird gezeigt, wie eine Bindung auf BindingContext festgelegt wird:

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

Gilt für: