Element Class

Definition

Provides the base class for all Microsoft.Maui.Controls hierarchal elements. This class contains all the methods and properties required to represent an element in the Microsoft.Maui.Controls hierarchy.

public ref class Element abstract : Microsoft::Maui::Controls::BindableObject, Microsoft::Maui::Controls::IEffectControlProvider, Microsoft::Maui::Controls::IElementController, Microsoft::Maui::Controls::Internals::INameScope, Microsoft::Maui::IElement, Microsoft::Maui::IVisualTreeElement
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.IElement, 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
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 IEffectControlProvider, IElement, IElementController, INameScope, IVisualTreeElement
Public MustInherit Class Element
Inherits BindableObject
Implements IContextFlyoutElement, IEffectControlProvider, IElement, IElementController, INameScope, IToolTipElement, IVisualTreeElement
Inheritance
Derived
Implements

Remarks

Important categories of visual elements are noted in the following table:

ClassDescription
VisualElement A Element that occupies an area on the screen, has a visual appearance, and can obtain touch input.
Cell Cells are elements meant to be added to ListView or TableView.
Page A VisualElement that occupies most or all of the screen and contains a single child.
Layout Layout have a single child of type View, while subclasses of Layout have a collection of multiple children views, including other layouts.
Controls and specialized Views The lower part of the diagram shows the Microsoft.Maui.Controls classes for universally-available controls, such as Buttons and TableViews.

Constructors

Element()

Fields

AutomationIdProperty

The backing store for the AutomationId field.

ClassIdProperty

Identifies the ClassId bindable property.

ControlsElementMapper

Properties

AutomationId

Gets or sets a value that allows the automation framework to find and interact with this element.

BindingContext

Gets or sets object that contains the properties that will be targeted by the bound properties that belong to this BindableObject.

(Inherited from BindableObject)
ClassId

Gets or sets a value used to identify a collection of semantically similar elements.

Dispatcher (Inherited from BindableObject)
EffectControlProvider

For internal use by the Microsoft.Maui.Controls platform.

Effects

A list of the effects that are applied to this item.

Handler
Id

Gets a value that can be used to uniquely identify an element through the run of an application.

LogicalChildren
Obsolete.

For internal use by the Microsoft.Maui.Controls platform.

Parent

Gets or sets the parent element of the element.

RealParent

For internal use by the Microsoft.Maui.Controls platform.

StyleId

Gets or sets a user defined value to uniquely identify the element.

Methods

ApplyBindings() (Inherited from BindableObject)
ClearValue(BindableProperty)

Clears any value set by SetValue for property.

(Inherited from BindableObject)
ClearValue(BindablePropertyKey)

Clears any value set by SetValue for the property that is identified by propertyKey.

(Inherited from BindableObject)
CoerceValue(BindableProperty) (Inherited from BindableObject)
CoerceValue(BindablePropertyKey) (Inherited from BindableObject)
EffectIsAttached(String)

For internal use by the Microsoft.Maui.Controls platform.

FindByName(String)

Returns the element that has the specified name.

GetValue(BindableProperty)

Returns the value that is contained in the BindableProperty.

(Inherited from BindableObject)
IsSet(BindableProperty)

Returns true if the target property exists and has been set.

(Inherited from BindableObject)
MapAutomationPropertiesExcludedWithChildren(IElementHandler, Element)
MapAutomationPropertiesIsInAccessibleTree(IElementHandler, Element)
OnBindingContextChanged()
OnChildAdded(Element)
OnChildRemoved(Element, Int32)
OnHandlerChanged()
OnHandlerChanging(HandlerChangingEventArgs)
OnParentChanged()
OnParentChanging(ParentChangingEventArgs)
OnParentSet()
OnPropertyChanged(String)
OnPropertyChanging(String) (Inherited from BindableObject)
RemoveBinding(BindableProperty)

Removes a previously set binding.

(Inherited from BindableObject)
RemoveDynamicResource(BindableProperty)

Removes a previously set dynamic resource

SetBinding(BindableProperty, BindingBase)

Assigns a binding to a property.

(Inherited from BindableObject)
SetDynamicResource(BindableProperty, String)

Sets the BindableProperty property of this element to be updated via the DynamicResource with the provided key.

SetValue(BindableProperty, Object)

Sets the value of the specified property.

(Inherited from BindableObject)
SetValue(BindablePropertyKey, Object)

Sets the value of the propertyKey.

(Inherited from BindableObject)
SetValueCore(BindableProperty, Object, SetValueFlags)

For internal use by the Microsoft.Maui.Controls platform.

(Inherited from BindableObject)
SetValueFromRenderer(BindableProperty, Object)

For internal use by the Microsoft.Maui.Controls platform.

SetValueFromRenderer(BindablePropertyKey, Object)

For internal use by the Microsoft.Maui.Controls platform.

UnapplyBindings() (Inherited from BindableObject)

Events

BindingContextChanged (Inherited from BindableObject)
ChildAdded
ChildRemoved
DescendantAdded
DescendantRemoved
HandlerChanged
HandlerChanging
ParentChanged
ParentChanging
PropertyChanged (Inherited from BindableObject)
PropertyChanging (Inherited from BindableObject)

Explicit Interface Implementations

IContextFlyoutElement.ContextFlyout
IDynamicResourceHandler.SetDynamicResource(BindableProperty, String) (Inherited from BindableObject)
IEffectControlProvider.RegisterEffect(Effect)
IElement.Parent
IElementController.Descendants()
IElementController.LogicalChildren
IElementController.SetValueFromRenderer(BindableProperty, Object)
INameScope.RegisterName(String, Object)
INameScope.UnregisterName(String)
IToolTipElement.ToolTip
IVisualTreeElement.GetVisualChildren()
IVisualTreeElement.GetVisualParent()

Extension Methods

GetPropertyIfSet<T>(BindableObject, BindableProperty, T)
SetAppTheme<T>(BindableObject, BindableProperty, T, T)
SetAppThemeColor(BindableObject, BindableProperty, Color, Color)
SetBinding(BindableObject, BindableProperty, String, BindingMode, IValueConverter, String)

Creates and applies a binding to a property.

FindByName<T>(Element, String)
ToHandler(IElement, IMauiContext)
ToPlatform(IElement, IMauiContext)
GetVisualElementWindow(IVisualTreeElement)

Gets the Window containing the Visual Tree Element, if the element is contained within one.

GetVisualTreeDescendants(IVisualTreeElement)

Gets the entire hierarchy of descendants as a list of children for a given Visual Tree Element.

GetVisualTreeElements(IVisualTreeElement, Point)

Gets list of a Visual Tree Element's children based off of a given Point.

GetVisualTreeElements(IVisualTreeElement, Rect)

Gets list of a Visual Tree Elements children based off of a rectangle.

GetVisualTreeElements(IVisualTreeElement, Double, Double)

Gets list of a Visual Tree Elements children based off of a given x, y point.

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

Gets list of a Visual Tree Elements children based off of a rectangle defined by its coordinates which are specified in platform units, not pixels.

Applies to