BindableObject 類別

定義

提供一種機制,可將數據變更從一個對象傳播到另一個物件。 啟用驗證、類型強制型轉和事件系統。

public ref class BindableObject abstract : Microsoft::Maui::Controls::Internals::IDynamicResourceHandler, System::ComponentModel::INotifyPropertyChanged
public abstract class BindableObject : Microsoft.Maui.Controls.Internals.IDynamicResourceHandler, System.ComponentModel.INotifyPropertyChanged
type BindableObject = class
    interface INotifyPropertyChanged
    interface IDynamicResourceHandler
Public MustInherit Class BindableObject
Implements IDynamicResourceHandler, INotifyPropertyChanged
繼承
BindableObject
衍生
實作

備註

類別 BindableObject 提供資料儲存機制,可讓應用程式開發人員同步處理對象之間的數據,以回應MVVM設計模式中的檢視和檢視模型之間的變更。 命名空間中的所有 Microsoft.Maui.Controls 視覺元素都繼承自 BindableObject 類別,因此它們都可以用來系結其使用者介面背後的數據。

建構函式

BindableObject()

初始化 BindableObject 類別的新執行個體。

欄位

BindingContextProperty

BindingContextBindable 屬性。

屬性

BindingContext

取得或設定 對象,這個物件包含屬於這個 BindableObject之系結屬性的目標屬性。 這是可繫結屬性。

Dispatcher

取得建立這個可系結物件時可用的發送器,否則會嘗試尋找最接近的可用發送器, (可能是視窗/應用程式的) 。

方法

ApplyBindings()

將所有目前的系結套用至 BindingContext

ClearValue(BindableProperty)

清除先前為可系結屬性設定的任何值。

ClearValue(BindablePropertyKey)

清除先前針對可系結屬性設定的任何值,其索引鍵所識別。

CoerceValue(BindableProperty)

強制指定可系結屬性的值。 這是藉由叫用 BindableProperty.CoerceValueDelegate 指定的可系結屬性來完成。

CoerceValue(BindablePropertyKey)

強制指定可系結屬性的值。 這是藉由叫用 BindableProperty.CoerceValueDelegate 指定的可系結屬性來完成。

GetValue(BindableProperty)

傳回包含在指定可系結屬性中的值。

IsSet(BindableProperty)

判斷可系結屬性是否存在,且已設定值。

OnBindingContextChanged()

引發 BindingContextChanged 事件。

OnPropertyChanged(String)

引發 PropertyChanged 事件。

OnPropertyChanging(String)

引發 PropertyChanging 事件。

RemoveBinding(BindableProperty)

從可系結屬性中移除先前設定的系結。

SetBinding(BindableProperty, BindingBase)

將系結指派給可系結屬性。

SetInheritedBindingContext(BindableObject, Object)

設定巢狀項目的繼承內容。

SetValue(BindableProperty, Object)

設定指定可系結屬性的值。

SetValue(BindablePropertyKey, Object)

設定指定可系結屬性的值。

SetValueCore(BindableProperty, Object, SetValueFlags)

供 Microsoft.Maui.Controls 平台內部使用。

UnapplyBindings()

從目前內容中移除所有目前的系結。

事件

BindingContextChanged

發生於 BindingContext 屬性的值變更時。

PropertyChanged

當屬性值變更時發生。

PropertyChanging

當屬性值變更中時發生。

明確介面實作

IDynamicResourceHandler.SetDynamicResource(BindableProperty, String)

提供一種機制,可將數據變更從一個對象傳播到另一個物件。 啟用驗證、類型強制型轉和事件系統。

擴充方法

GetPropertyIfSet<T>(BindableObject, BindableProperty, T)

提供一種機制,可將數據變更從一個對象傳播到另一個物件。 啟用驗證、類型強制型轉和事件系統。

SetAppTheme<T>(BindableObject, BindableProperty, T, T)

提供一種機制,可將數據變更從一個對象傳播到另一個物件。 啟用驗證、類型強制型轉和事件系統。

SetAppThemeColor(BindableObject, BindableProperty, Color, Color)

提供一種機制,可將數據變更從一個對象傳播到另一個物件。 啟用驗證、類型強制型轉和事件系統。

SetBinding(BindableObject, BindableProperty, String, BindingMode, IValueConverter, String)

建立並將繫結套用至屬性。

適用於