BindableObject.BindingContextProperty 欄位
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
的 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
欄位值
備註
一般而言,如果在 BindingContext 進行所有呼叫 SetBinding(BindableProperty, BindingBase) 之後設定,運行時間效能會更好。
下列範例示範如何將系結設定為 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"}};
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應