Xamarin.Forms Guides | Samples

Xamarin.Forms.Element Class

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

See Also: Element


public abstract class Element : BindableObject, IElementController, INameScope


The following diagram shows the classes derived from Element.

The diagram shows some important categories:

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


Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions:,,,,,,,

The members of Xamarin.Forms.Element are listed below.

See Also: BindableObject

Protected Constructors

Protected constructor used to initialize a the element.

Public Fields

static readonly
ClassIdPropertyBindableProperty. Identifies the ClassId bindable property.

Public Properties

AutomationIdString. Gets or sets a value that allows the automation framework to find and interact with this element.
ClassIdString. Gets or sets a value used to identify a collection of semantically similar elements.
EffectsIList<Effect>. A list of the effects that are applied to this item.
IdGuid. Gets a value that can be used to uniquely identify an element through the run of an application.
ParentElement. Gets or sets the parent element of the element.
ParentViewVisualElement. Gets the element which is the closest ancestor of this element that is a VisualElement.
StyleIdString. Gets or sets a user defined value to uniquely identify the element.

Public Methods

Removes a previously set dynamic resource
SetDynamicResource(BindableProperty, String)
Sets the BindableProperty property of this element to be updated via the DynamicResource with the provided key.

Protected Methods

Invoked whenever the binding context of the element changes. Implement this method to add class handling for this event.
Invoked whenever the Element.ChildAdded event needs to be emitted. Implement this method to add class handling for this event.
Invoked whenever the Element.ChildRemoved event needs to be emitted. Implement this method to add class handling for this event.
Invoked whenever the Parent of an element is set. Implement this method in order to add behavior when the element is added to a parent.
Method that is called when a bound property is changed.

Public Events

ChildAddedOccurs whenever a child element is added to the element.
ChildRemovedOccurs whenever a child element is removed from the element.
DescendantAddedOccurs whenever a child element is added to the elements subtree.
DescendantRemovedOccurs whenever a child element is removed from the elements subtree.

Explicitly Implemented Interface Members

Element$IElementController.EffectControlProviderIEffectControlProvider. For internal use only.
Element$IElementController.EffectIsAttached(String)For internal use only.
Element$INameScope.FindByName(String)Finds an object previously registered with Element.RegisterName.
Element$INameScope.FindByName(String)For internal use only.
Element$IElementController.LogicalChildrenSystem.Collections.ObjectModel.ReadOnlyCollection<Element>. For internal use only.
Element$INameScope.RegisterName(String,Lazy<Object>)Internal use only.
Element$INameScope.RegisterName(String,Object)Within an INameScope, creates an association between name and scopedElement.
Element$INameScope.RegisterName(String,Object)For internal use only.
Element$INameScope.RegisterName(String,Object,IXmlLineInfo)For internal use only.
Element$IElement.ResourceDictionaryIResourceDictionary. Internal.
Element$IElementController.SetValueFromRenderer(BindableProperty,Object)Sets a value from a renderer without breaking the binding on a bound property.
Element$IElementController.SetValueFromRenderer(BindablePropertyKey,Object)Sets a value from a renderer without breaking the binding on a bound property.
Element$INameScope.UnregisterName(String)Removes name from an INameScope.
Element$INameScope.UnregisterName(String)For internal use only.
Element$IElement.XamlParentWeakReference<Element>. Gets or sets a weak reference to the parent of this Element object.