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

Syntax

public abstract class Element : BindableObject, IElementController, INameScope

Remarks

The following diagram shows the classes derived from Element.

The diagram shows some important categories:

ClassDescription
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.

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.3.0.0, 1.3.3.0, 1.4.0.0, 1.5.0.0, 2.0.0.0

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.
[read-only]
EffectsIList<Effect>. A list of the effects that are applied to this item.
[read-only]
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.
[read-only]
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

RemoveDynamicResource(BindableProperty)
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

override
OnBindingContextChanged()
Invoked whenever the binding context of the element changes. Implement this method to add class handling for this event.
OnChildAdded(Element)
Invoked whenever the Element.ChildAdded event needs to be emitted. Implement this method to add class handling for this event.
OnChildRemoved(Element)
Invoked whenever the Element.ChildRemoved event needs to be emitted. Implement this method to add class handling for this event.
OnParentSet()
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.
override
OnPropertyChanged(String)
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$IElement.AddResourcesChangedListener(Action<Object,ResourcesChangedEventArgs>)Internal.
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.
[read-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)Internal.
Element$INameScope.RegisterName(String,Object,IXmlLineInfo)For internal use only.
Element$IElement.RemoveResourcesChangedListener(Action<Object,ResourcesChangedEventArgs>)Internal.
[read-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.