Xamarin.Forms Guides | Samples

Xamarin.Forms.VisualElement Class

A Element that occupies an area on the screen, has a visual appearance, and can obtain touch input.

See Also: VisualElement

Syntax

public class VisualElement : Element, IAnimatable, IVisualElementController

Remarks

The base class for most Xamarin.Forms on-screen elements. Provides most properties, events, and methods for presenting an item on screen.

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.4.0.0, 1.5.0.0, 2.0.0.0

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

See Also: Element

Public Fields

static readonly
AnchorXPropertyBindableProperty. Identifies the AnchorX bindable property.
static readonly
AnchorYPropertyBindableProperty. Identifies the AnchorY bindable property.
static readonly
BackgroundColorPropertyBindableProperty. Identifies the BackgroundColor bindable property.
static readonly
BehaviorsPropertyBindableProperty. Identifies the Behaviors bindable property.
static readonly
HeightPropertyBindableProperty. Identifies the Height bindable property.
static readonly
HeightRequestPropertyBindableProperty. Backing store for the HeightRequest property.
static readonly
InputTransparentPropertyBindableProperty. Identifies the InputTransparent bindable property.
static readonly
IsEnabledPropertyBindableProperty. Identifies the IsEnabled bindable property.
static readonly
IsFocusedPropertyBindableProperty. Identifies the IsFocused bindable property.
static readonly
IsVisiblePropertyBindableProperty. Identifies the IsVisible bindable property.
static readonly
MinimumHeightRequestPropertyBindableProperty. Backing store for the MinimumHeightRequest property.
static readonly
MinimumWidthRequestPropertyBindableProperty. Backing store for the MinimumWidthRequest property.
static readonly
NavigationPropertyBindableProperty. Identifies the Navigation bindable property.
static readonly
OpacityPropertyBindableProperty. Identifies the Opacity bindable property.
static readonly
RotationPropertyBindableProperty. Identifies the Rotation bindable property.
static readonly
RotationXPropertyBindableProperty. Identifies the RotationX bindable property.
static readonly
RotationYPropertyBindableProperty. Identifies the RotationY bindable property.
static readonly
ScalePropertyBindableProperty. Identifies the Scale bindable property.
static readonly
StylePropertyBindableProperty. Backing store for the Style property.
static readonly
TranslationXPropertyBindableProperty. Identifies the TranslationX bindable property.
static readonly
TranslationYPropertyBindableProperty. Identifies the TranslationY bindable property.
static readonly
TriggersPropertyBindableProperty. Identifies the Triggers bindable property.
static readonly
WidthPropertyBindableProperty. Identifies the Width bindable property.
static readonly
WidthRequestPropertyBindableProperty. Backing store for the WidthRequest property.
static readonly
XPropertyBindableProperty. Identifies the X bindable property.
static readonly
YPropertyBindableProperty. Identifies the Y bindable property.

Public Properties

AnchorXDouble. Gets or sets the X component of the center point for any transform, relative to the bounds of the element. This is a bindable property.
AnchorYDouble. Gets or sets the Y component of the center point for any transform, relative to the bounds of the element. This is a bindable property.
BackgroundColorColor. Gets or sets the color which will fill the background of a VisualElement. This is a bindable property.
[read-only]
BehaviorsIList<Behavior>. Gets the list of Behavior associated to this element. This is a bindable propery.
[read-only]
BoundsRectangle. Gets the bounds of the element.
[read-only]
HeightDouble. Gets the current rendered height of this element. This is a read-only bindable property.
HeightRequestDouble. Gets or sets the desired height override of this element.
InputTransparentBoolean. Gets or sets a value indicating whether this element should be involved in the user interaction cycle. This is a bindable property.
IsEnabledBoolean. Gets or sets a value indicating whether this element is enabled in the user interface. This is a bindable property.
[read-only]
IsFocusedBoolean. Gets a value indicating whether this element is focused currently. This is a bindable property.
IsVisibleBoolean. Gets or sets a value that determines whether this elements should be part of the visual tree or not. This is a bindable property.
MinimumHeightRequestDouble. Gets or sets a value which overrides the minimum height the element will request during layout.
MinimumWidthRequestDouble. Gets or sets a value which overrides the minimum width the element will request during layout.
[read-only]
NavigationINavigation. Gets the context aware navigation interface for the element.
OpacityDouble. Gets or sets the opacity value applied to the element when it is rendered. This is a bindable property.
ResourcesResourceDictionary. Gets or sets the local resource dictionary.
RotationDouble. Gets or sets the rotation about the Z-axis (affine rotation) when the element is rendered.
RotationXDouble. Gets or sets the rotation about the X-axis (perspective rotation) when the element is rendered.
RotationYDouble. Gets or sets the rotation about the Y-axis (perspective rotation) when the element is rendered.
ScaleDouble. Gets or sets the scale factor applied to the element.
StyleStyle. Gets or sets the style that defines how this visual element is displayed.
StyleClassIList<string>. Gets or sets the style class for the visual element.
TranslationXDouble. Gets or sets the X translation delta of the element.
TranslationYDouble. Gets or sets the Y translation delta of the element.
[read-only]
TriggersIList<TriggerBase>. Gets the list of Trigger associated to this element. This is a bindable property.
[read-only]
WidthDouble. Gets the current rendered width of this element. This is a read-only bindable property.
WidthRequestDouble. Gets or sets the desired width override of this element.
[read-only]
XDouble. Gets the current X position of this element. This is a read-only bindable property.
[read-only]
YDouble. Gets the current Y position of this element. This is a read-only bindable property.

Public Methods

BatchBegin()
Signals the start of a batch of changes to the elements properties.
BatchCommit()
Signals the end of a batch of commands to the element and that those commands should now be committed.
Focus() : Boolean
Attemps to set focus to this element.
GetSizeRequest(Double, Double) : SizeRequest
Returns the SizeRequest of the element. Calling this method begins the measure pass of a layout cycle.
Layout(Rectangle)
Updates the bounds of the element during the layout cycle.
Measure(Double, Double, MeasureFlags) : SizeRequest
Returns the minimum size that a visual element needs in order to be displayed on the device.
Unfocus()
Unsets focus to this element.

Protected Methods

InvalidateMeasure()
Method that is called to invalidate the layout of this VisualElement. Raises the VisualElement.MeasureInvalidated event.
override
OnChildAdded(Element)
Application developers can override this method to respond when a child is added.
override
OnChildRemoved(Element)
Application developers can override this method to respond when a child is removed.
OnChildrenReordered()
Invoked whenever the VisualElement.ChildrenReordered event is about to be emitted. Implement this method to add class handling for this event.
OnMeasure(Double, Double) : SizeRequest
Method that is called when a layout measurement happens.
override
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.
OnSizeAllocated(Double, Double)
This method is called when the size of the element is set during a layout cycle. This method is called directly before the VisualElement.SizeChanged event is emitted. Implement this method to add class handling for this event.
OnSizeRequest(Double, Double) : SizeRequest
This method is called during the measure pass of a layout cycle to get the desired size of an element.
SizeAllocated(Double, Double)
SizeAllocated is called during a layout cycle to signal the start of a sub-tree layout.

Public Events

ChildrenReorderedOccurs when the Children of a VisualElement have been re-ordered.
FocusedOccurs when the element receives focus.
MeasureInvalidatedEvent that is raised when the layout of a visual element is invalidated.
SizeChangedOccurs when either the Width or the Height properties change value on this element.
UnfocusedOccurs when the element loses focus.

Explicitly Implemented Interface Members

VisualElement$IVisualElementController.InvalidateMeasure(InvalidationTrigger)This method is for internal use.
VisualElement$IVisualElementController.NativeSizeChangedInvalidates the measure when the native size of the element changes.