Element 類別

定義

提供所有 Microsoft.Maui.Controls 階層專案的基類。 這個類別包含代表 Microsoft.Maui.Controls 階層中專案所需的所有方法和屬性。

public ref class Element abstract : Microsoft::Maui::Controls::BindableObject, Microsoft::Maui::Controls::IEffectControlProvider, Microsoft::Maui::Controls::IElementController, Microsoft::Maui::Controls::Internals::INameScope, Microsoft::Maui::IContextFlyoutElement, Microsoft::Maui::IElement, Microsoft::Maui::IToolTipElement, Microsoft::Maui::IVisualTreeElement
public abstract class Element : Microsoft.Maui.Controls.BindableObject, Microsoft.Maui.Controls.IEffectControlProvider, Microsoft.Maui.Controls.IElementController, Microsoft.Maui.Controls.Internals.INameScope, Microsoft.Maui.IContextFlyoutElement, Microsoft.Maui.IElement, Microsoft.Maui.IToolTipElement, Microsoft.Maui.IVisualTreeElement
type Element = class
    inherit BindableObject
    interface INameScope
    interface IElementController
    interface IVisualTreeElement
    interface IElement
    interface IEffectControlProvider
    interface IToolTipElement
    interface IContextFlyoutElement
Public MustInherit Class Element
Inherits BindableObject
Implements IContextFlyoutElement, IEffectControlProvider, IElement, IElementController, INameScope, IToolTipElement, IVisualTreeElement
繼承
衍生
實作

備註

下表說明視覺元素的重要類別:

類別 描述
VisualElement Element,佔用螢幕上的區域、具有視覺外觀,而且可以取得觸控輸入。
Cell 儲存格都是要新增至 ListViewTableView 的項目。
Page VisualElement,佔用大部分或全部螢幕,並包含單一子系。
Layout Layout具有類型的單一子系 View ,而的子類別 Layout 具有多個子系視圖的集合,包括其他版面配置。
控件和特製化 View圖表的下半部顯示適用於通用控件的 Microsoft.Maui.Controls 類別,例如 ButtonTableView

建構函式

Element()

提供所有 Microsoft.Maui.Controls 階層專案的基類。 這個類別包含代表 Microsoft.Maui.Controls 階層中專案所需的所有方法和屬性。

欄位

AutomationIdProperty

AutomationIdBindable 屬性。

ClassIdProperty

ClassIdBindable 屬性。

ControlsElementMapper
已淘汰.

將UI資訊對應至輔助功能服務的平臺特定實作

屬性

AutomationId

取得或設定值,允許自動化架構尋找此項目並與之互動。

BindingContext

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

(繼承來源 BindableObject)
ClassId

取得或設定值,用來識別語意類似項目的集合。

Dispatcher

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

(繼承來源 BindableObject)
EffectControlProvider

供 .NET MAUI 內部使用。

Effects

取得或設定將在運行時間套用至項目的樣式和屬性。

Handler

取得或設定這個項目的相關處理程式。

Id

取得值,這個值可用來在應用程式執行期間唯一識別專案。

LogicalChildren
已淘汰.

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

Parent

取得或設定這個專案的父 Element 代。

RealParent

供 .NET MAUI 內部使用。

StyleId

取得或設定使用者定義值來唯一識別項目。

方法

AddLogicalChild(Element)

Element將加入邏輯子系。

ApplyBindings()

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

(繼承來源 BindableObject)
ClearLogicalChildren()

拿掉所有子 Element系。

ClearValue(BindableProperty)

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

(繼承來源 BindableObject)
ClearValue(BindablePropertyKey)

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

(繼承來源 BindableObject)
CoerceValue(BindableProperty)

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

(繼承來源 BindableObject)
CoerceValue(BindablePropertyKey)

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

(繼承來源 BindableObject)
EffectIsAttached(String)

供 .NET MAUI 內部使用。

FindByName(String)

傳回具有指定名稱的元素。

GetValue(BindableProperty)

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

(繼承來源 BindableObject)
InsertLogicalChild(Int32, Element)

Element 插入至位於指定索引處的邏輯子系。

IsSet(BindableProperty)

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

(繼承來源 BindableObject)
MapAutomationPropertiesExcludedWithChildren(IElementHandler, Element)

將抽象 ExcludedWithChildrenProperty 屬性對應至平臺特定的實作。

MapAutomationPropertiesIsInAccessibleTree(IElementHandler, Element)

將抽象 IsInAccessibleTreeProperty 屬性對應至平臺特定的實作。

OnBindingContextChanged()

只要項目的繫結內容變更時就叫用。 實作這個方法可為此事件加入類別處理。

OnChildAdded(Element)

引發 ChildAdded 事件。 實作這個方法可為此事件加入類別處理。

OnChildRemoved(Element, Int32)

引發 ChildRemoved 事件。 實作這個方法以新增此事件的類別處理

OnHandlerChanged()

在衍生類別中覆寫時,應該引發 HandlerChanged 事件。

OnHandlerChanging(HandlerChangingEventArgs)

在衍生類別中覆寫時,應該引發 HandlerChanging 事件。

OnParentChanged()

在衍生類別中覆寫時,應該引發 ParentChanged 事件。

OnParentChanging(ParentChangingEventArgs)

在衍生類別中覆寫時,應該引發 ParentChanging 事件。

OnParentSet()

引發內部) 事件 (ParentSet 。 實作這個方法,以便在項目新增至父系時新增行為。

OnPropertyChanged(String)

繫結屬性變更時呼叫的方法。

OnPropertyChanging(String)

引發 PropertyChanging 事件。

(繼承來源 BindableObject)
RemoveBinding(BindableProperty)

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

(繼承來源 BindableObject)
RemoveDynamicResource(BindableProperty)

拿掉先前設定的動態資源。

RemoveLogicalChild(Element)

從邏輯子系中移除第一個出現的特定 Element 專案。

SetBinding(BindableProperty, BindingBase)

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

(繼承來源 BindableObject)
SetDynamicResource(BindableProperty, String)

使用提供的索引鍵, BindableProperty 設定要透過 DynamicResource 更新這個項目的 屬性。

SetValue(BindableProperty, Object)

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

(繼承來源 BindableObject)
SetValue(BindablePropertyKey, Object)

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

(繼承來源 BindableObject)
SetValueCore(BindableProperty, Object, SetValueFlags)

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

(繼承來源 BindableObject)
SetValueFromRenderer(BindableProperty, Object)

供 .NET MAUI 內部使用。

SetValueFromRenderer(BindablePropertyKey, Object)

供 .NET MAUI 內部使用。

UnapplyBindings()

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

(繼承來源 BindableObject)

事件

BindingContextChanged

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

(繼承來源 BindableObject)
ChildAdded

每當子專案加入至 項目時引發。

ChildRemoved

每當從專案中移除子項目時引發。

DescendantAdded

每當子專案加入至專案的子樹時引發。

DescendantRemoved

每當從專案子樹中移除子項目時引發。

HandlerChanged

每當項目的處理程式變更時引發。

HandlerChanging

每當項目的處理程序開始變更時引發。

ParentChanged

每當專案的父代變更時引發。

ParentChanging

每當項目的 開始變更時引發。

PropertyChanged

當屬性值變更時發生。

(繼承來源 BindableObject)
PropertyChanging

當屬性值變更中時發生。

(繼承來源 BindableObject)

明確介面實作

IContextFlyoutElement.ContextFlyout

ContextFlyout取得檢視的 。 功能表飛出視窗、功能表飛出視窗子專案,以及功能表飛出視窗分隔符可以新增至內容飛出視窗。

IDynamicResourceHandler.SetDynamicResource(BindableProperty, String)

提供所有 Microsoft.Maui.Controls 階層專案的基類。 這個類別包含代表 Microsoft.Maui.Controls 階層中專案所需的所有方法和屬性。

(繼承來源 BindableObject)
IEffectControlProvider.RegisterEffect(Effect)

提供所有 Microsoft.Maui.Controls 階層專案的基類。 這個類別包含代表 Microsoft.Maui.Controls 階層中專案所需的所有方法和屬性。

IElement.Parent

取得專案的父代。

IElementController.Descendants()

供 .NET MAUI 內部使用。

IElementController.LogicalChildren

供 .NET MAUI 內部使用。

IElementController.SetValueFromRenderer(BindableProperty, Object)

供 .NET MAUI 內部使用。

INameScope.RegisterName(String, Object)

供 .NET MAUI 內部使用。

INameScope.UnregisterName(String)

供 .NET MAUI 內部使用。

IToolTipElement.ToolTip

代表小型矩形彈出視窗,當使用者將指標放在檢視上時,顯示檢視用途的簡短描述。

IVisualTreeElement.GetVisualChildren()

取得元素視覺子系的唯讀清單。

IVisualTreeElement.GetVisualParent()

取得專案的可視化父代。

擴充方法

GetPropertyIfSet<T>(BindableObject, BindableProperty, T)

提供所有 Microsoft.Maui.Controls 階層專案的基類。 這個類別包含代表 Microsoft.Maui.Controls 階層中專案所需的所有方法和屬性。

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

提供所有 Microsoft.Maui.Controls 階層專案的基類。 這個類別包含代表 Microsoft.Maui.Controls 階層中專案所需的所有方法和屬性。

SetAppThemeColor(BindableObject, BindableProperty, Color, Color)

提供所有 Microsoft.Maui.Controls 階層專案的基類。 這個類別包含代表 Microsoft.Maui.Controls 階層中專案所需的所有方法和屬性。

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

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

FindByName<T>(Element, String)

提供所有 Microsoft.Maui.Controls 階層專案的基類。 這個類別包含代表 Microsoft.Maui.Controls 階層中專案所需的所有方法和屬性。

ToHandler(IElement, IMauiContext)

提供所有 Microsoft.Maui.Controls 階層專案的基類。 這個類別包含代表 Microsoft.Maui.Controls 階層中專案所需的所有方法和屬性。

ToPlatform(IElement, IMauiContext)

提供所有 Microsoft.Maui.Controls 階層專案的基類。 這個類別包含代表 Microsoft.Maui.Controls 階層中專案所需的所有方法和屬性。

GetVisualElementWindow(IVisualTreeElement)

如果專案包含在其中,則取得包含可視化樹狀結構專案的 Window。

GetVisualTreeDescendants(IVisualTreeElement)

取得子系的整個階層,做為指定可視化樹狀結構專案的子系列表。

GetVisualTreeElements(IVisualTreeElement, Point)

根據指定的Point,取得可視化樹狀結構專案的子系列表。

GetVisualTreeElements(IVisualTreeElement, Rect)

根據矩形取得可視化樹狀結構元素子系的清單。

GetVisualTreeElements(IVisualTreeElement, Double, Double)

根據指定的 x、y 點,取得可視化樹狀結構元素子系的清單。

GetVisualTreeElements(IVisualTreeElement, Double, Double, Double, Double)

根據其座標所定義的矩形,取得可視化樹狀結構元素子系的清單,該矩形是以平台單位指定,而不是圖元。

適用於