Element Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides the base class for all Xamarin.Forms hierarchal elements. This class contains all the methods and properties required to represent an element in the Xamarin.Forms hierarchy.
public abstract class Element : Xamarin.Forms.BindableObject, Xamarin.Forms.IElementController, Xamarin.Forms.Internals.INameScope
type Element = class
inherit BindableObject
interface INameScope
interface IElementController
- Inheritance
- Derived
- Implements
Remarks
Important categories of visual elements are noted in the following table:
Class | Description |
---|---|
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<T> 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. |
Constructors
Element() |
Protected constructor used to initialize a the element. |
Fields
AutomationIdProperty |
The backing store for the AutomationId field. |
ClassIdProperty |
Identifies the ClassId bindable property. |
MenuProperty |
Backing store for the attached menu property. |
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 Xamarin.Forms platform. |
Effects |
A list of the effects that are applied to this item. |
Id |
Gets a value that can be used to uniquely identify an element through the run of an application. |
LogicalChildren |
For internal use by the Xamarin.Forms platform. |
Parent |
Gets or sets the parent element of the element. |
ParentView |
Obsolete.
Gets the element which is the closest ancestor of this element that is a VisualElement. |
Platform | |
RealParent |
For internal use by the Xamarin.Forms platform. |
StyleId |
Gets or sets a user defined value to uniquely identify the element. |
Methods
ApplyBindings() |
Apply the bindings to BindingContext. (Inherited from BindableObject) |
ClearValue(BindableProperty) |
Clears any value set by SetValue for |
ClearValue(BindablePropertyKey) |
Clears any value set by SetValue for the property that is identified by |
CoerceValue(BindableProperty) | (Inherited from BindableObject) |
CoerceValue(BindablePropertyKey) | (Inherited from BindableObject) |
Descendants() |
For internal use by the Xamarin.Forms platform. |
EffectIsAttached(String) |
For internal use by the Xamarin.Forms platform. |
FindByName(String) |
Returns the element that has the specified name. |
GetMenu(BindableObject) |
Gets the Menu object for |
GetValue(BindableProperty) |
Returns the value that is contained in the BindableProperty. (Inherited from BindableObject) |
GetValues(BindableProperty, BindableProperty, BindableProperty) |
Obsolete.
For internal use by the Xamarin.Forms platform. (Inherited from BindableObject) |
GetValues(BindableProperty, BindableProperty) |
Obsolete.
For internal use by the Xamarin.Forms platform. (Inherited from BindableObject) |
IsSet(BindableProperty) |
Returns |
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 ChildAdded event needs to be emitted. Implement this method to add class handling for this event. |
OnChildRemoved(Element, Int32) | |
OnChildRemoved(Element) |
Obsolete.
Invoked whenever the 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. |
OnPropertyChanged(String) |
Method that is called when a bound property is changed. |
OnPropertyChanging(String) |
Call this method from a child class to notify that a change is going to happen on a property. (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. |
SetMenu(BindableObject, Menu) |
Sets the menu for |
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 Xamarin.Forms platform. (Inherited from BindableObject) |
SetValueFromRenderer(BindableProperty, Object) |
For internal use by the Xamarin.Forms platform. |
SetValueFromRenderer(BindablePropertyKey, Object) |
For internal use by the Xamarin.Forms platform. |
UnapplyBindings() |
Unapplies all previously set bindings. (Inherited from BindableObject) |
Events
BindingContextChanged |
Raised whenever the BindingContext property changes. (Inherited from BindableObject) |
ChildAdded |
Occurs whenever a child element is added to the element. |
ChildRemoved |
Occurs whenever a child element is removed from the element. |
DescendantAdded |
Occurs whenever a child element is added to the elements subtree. |
DescendantRemoved |
Occurs whenever a child element is removed from the elements subtree. |
PlatformSet | |
PropertyChanged |
Raised when a property has changed. (Inherited from BindableObject) |
PropertyChanging |
Raised when a property is about to change. (Inherited from BindableObject) |
Explicit Interface Implementations
IDynamicResourceHandler.SetDynamicResource(BindableProperty, String) |
For internal use by the Xamarin.Forms platform. (Inherited from BindableObject) |
IElementController.SetValueFromRenderer(BindableProperty, Object) |
For internal use by the Xamarin.Forms platform. |
INameScope.RegisterName(String, Object) |
For internal use only. |
Extension Methods
GetPropertyIfSet<T>(BindableObject, BindableProperty, T) | |
SetAppThemeColor(BindableObject, BindableProperty, Color, Color) | |
SetBinding(BindableObject, BindableProperty, String, BindingMode, IValueConverter, String) |
Creates and applies a binding to a property. |
SetBinding<TSource>(BindableObject, BindableProperty, Expression<Func<TSource,Object>>, BindingMode, IValueConverter, String) |
Obsolete.
Creates and applies a binding from an expression. |
SetOnAppTheme<T>(BindableObject, BindableProperty, T, T) | |
FindByName<T>(Element, String) |
Returns the instance of type |