Xamarin.Forms Guides | Samples

Xamarin.Forms.Layout Class

Provides the base class for all Layout elements. Use Layout elements to position and size child elements in Forms applications.

See Also: Layout

Syntax

public abstract class Layout : View, ILayout, ILayoutController

See Also

Remarks

Subtypes of Layout include ContentView, ScrollView, and Layout`1, as shown in the following diagram.

The Layout`1.Children property of Layout`1 contains a list of children of the parameterized type T, which must be a type of View. Since Layout is itself a subclass of View, this allows Layouts to hold sub-layouts, scrolling regions, etc.

XAML for Xamarin.Forms supports the following properties for the Layout class:

PropertyValue
IsClippedToBounds

true or false, to indicate whether the layout is clipped to its bounding rectangle.

Padding

A comma-separated list of 4 integers that represent a Thickness structure.

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

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

See Also: View

Protected Constructors

Intitializes a new Layout instance.

Public Fields

static readonly
IsClippedToBoundsPropertyBindableProperty. Identifies the Layout.IsClippedToBounds bindable property.
static readonly
PaddingPropertyBindableProperty. Identifies the Padding bindable property.

Public Properties

IsClippedToBoundsBoolean. Gets or sets a value which determines if the Layout should clip its children to its bounds.
PaddingThickness. Gets or sets the inner padding of the Layout.

Public Methods

ForceLayout()
Forces a layout cycle on the element and all of its descendants.
override
GetSizeRequest(Double, Double) : SizeRequest
Returns the SizeRequest of the Layout. Calling this method begins the measure pass of a layout cycle.
static
LayoutChildIntoBoundingRegion(VisualElement, Rectangle)
Positions a child element into a bounding region while respecting the child elements VisualElement.HorizontalOptions and VisualElement.VerticalOptions.
LowerChild(View)
Sends a child to the back of the visual stack.
RaiseChild(View)
Sends a child to the front of the visual stack.

Protected Methods

InvalidateLayout()
Invalidates the current layout.
abstract
LayoutChildren(Double, Double, Double, Double)
Positions and sizes the children of a Layout.
OnChildMeasureInvalidated()
Invoked whenever a child of the layout has emitted VisualElement.MeaureInvalidated. Implement this method to add class handling for this event.
OnChildMeasureInvalidated(Object, EventArgs)
Invoked whenever a child of the layout has emitted VisualElement.MeaureInvalidated. Implement this method to add class handling for this event.
override
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.
ShouldInvalidateOnChildAdded(View) : Boolean
When implemented, should return true if child should call VisualElement.InvalidateMeasure, and to return false if it should not.
ShouldInvalidateOnChildRemoved(View) : Boolean
When implemented, should return true if child should call VisualElement.InvalidateMeasure when it is removed, and to return false if it should not.
UpdateChildrenLayout()
Instructs the layout to relayout all of its children.

Public Events

LayoutChangedOccurs at the end of a layout cycle if any of the child element's VisualElement.Bounds have changed.

Explicitly Implemented Interface Members