Table of Contents

Class Layoutable

Namespace
Avalonia.Layout
Assembly
Avalonia.Base.dll

Implements layout-related functionality for a control.

public class Layoutable : Visual, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed
Inheritance
Layoutable
Implements
Derived
Inherited Members
Extension Methods

Constructors

Layoutable()

public Layoutable()

Fields

DesiredSizeProperty

Defines the DesiredSize property.

public static readonly DirectProperty<Layoutable, Size> DesiredSizeProperty

Field Value

DirectProperty<Layoutable, Size>

HeightProperty

Defines the Height property.

public static readonly StyledProperty<double> HeightProperty

Field Value

StyledProperty<double>

HorizontalAlignmentProperty

Defines the HorizontalAlignment property.

public static readonly StyledProperty<HorizontalAlignment> HorizontalAlignmentProperty

Field Value

StyledProperty<HorizontalAlignment>

MarginProperty

Defines the Margin property.

public static readonly StyledProperty<Thickness> MarginProperty

Field Value

StyledProperty<Thickness>

MaxHeightProperty

Defines the MaxHeight property.

public static readonly StyledProperty<double> MaxHeightProperty

Field Value

StyledProperty<double>

MaxWidthProperty

Defines the MaxWidth property.

public static readonly StyledProperty<double> MaxWidthProperty

Field Value

StyledProperty<double>

MinHeightProperty

Defines the MinHeight property.

public static readonly StyledProperty<double> MinHeightProperty

Field Value

StyledProperty<double>

MinWidthProperty

Defines the MinWidth property.

public static readonly StyledProperty<double> MinWidthProperty

Field Value

StyledProperty<double>

UseLayoutRoundingProperty

Defines the UseLayoutRounding property.

public static readonly StyledProperty<bool> UseLayoutRoundingProperty

Field Value

StyledProperty<bool>

VerticalAlignmentProperty

Defines the VerticalAlignment property.

public static readonly StyledProperty<VerticalAlignment> VerticalAlignmentProperty

Field Value

StyledProperty<VerticalAlignment>

WidthProperty

Defines the Width property.

public static readonly StyledProperty<double> WidthProperty

Field Value

StyledProperty<double>

Properties

DesiredSize

Gets the size that this element computed during the measure pass of the layout process.

public Size DesiredSize { get; }

Property Value

Size

Height

Gets or sets the height of the element.

public double Height { get; set; }

Property Value

double

HorizontalAlignment

Gets or sets the element's preferred horizontal alignment in its parent.

public HorizontalAlignment HorizontalAlignment { get; set; }

Property Value

HorizontalAlignment

IsArrangeValid

Gets a value indicating whether the control's layouts arrange is valid.

public bool IsArrangeValid { get; }

Property Value

bool

IsMeasureValid

Gets a value indicating whether the control's layout measure is valid.

public bool IsMeasureValid { get; }

Property Value

bool

Margin

Gets or sets the margin around the element.

public Thickness Margin { get; set; }

Property Value

Thickness

MaxHeight

Gets or sets the maximum height of the element.

public double MaxHeight { get; set; }

Property Value

double

MaxWidth

Gets or sets the maximum width of the element.

public double MaxWidth { get; set; }

Property Value

double

MinHeight

Gets or sets the minimum height of the element.

public double MinHeight { get; set; }

Property Value

double

MinWidth

Gets or sets the minimum width of the element.

public double MinWidth { get; set; }

Property Value

double

UseLayoutRounding

Gets or sets a value that determines whether the element should be snapped to pixel boundaries at layout time.

public bool UseLayoutRounding { get; set; }

Property Value

bool

VerticalAlignment

Gets or sets the element's preferred vertical alignment in its parent.

public VerticalAlignment VerticalAlignment { get; set; }

Property Value

VerticalAlignment

Width

Gets or sets the width of the element.

public double Width { get; set; }

Property Value

double

Methods

AffectsArrange<T>(params AvaloniaProperty[])

Marks a property as affecting the control's arrangement.

protected static void AffectsArrange<T>(params AvaloniaProperty[] properties) where T : Layoutable

Parameters

properties AvaloniaProperty[]

The properties.

Type Parameters

T

The control which the property affects.

Remarks

After a call to this method in a control's static constructor, any change to the property will cause InvalidateArrange() to be called on the element.

AffectsMeasure<T>(params AvaloniaProperty[])

Marks a property as affecting the control's measurement.

protected static void AffectsMeasure<T>(params AvaloniaProperty[] properties) where T : Layoutable

Parameters

properties AvaloniaProperty[]

The properties.

Type Parameters

T

The control which the property affects.

Remarks

After a call to this method in a control's static constructor, any change to the property will cause InvalidateMeasure() to be called on the element.

ApplyTemplate()

Creates the visual children of the control, if necessary

public virtual void ApplyTemplate()

Arrange(Rect)

Arranges the control and its children.

public void Arrange(Rect rect)

Parameters

rect Rect

The control's new bounds.

ArrangeCore(Rect)

The default implementation of the control's arrange pass.

protected virtual void ArrangeCore(Rect finalRect)

Parameters

finalRect Rect

The control's new bounds.

Remarks

This method calls ArrangeOverride(Size) which is probably the method you want to override in order to modify a control's arrangement.

ArrangeOverride(Size)

Positions child elements as part of a layout pass.

protected virtual Size ArrangeOverride(Size finalSize)

Parameters

finalSize Size

The size available to the control.

Returns

Size

The actual size used.

InvalidateArrange()

Invalidates the arrangement of the control and queues a new layout pass.

public void InvalidateArrange()

InvalidateMeasure()

Invalidates the measurement of the control and queues a new layout pass.

public void InvalidateMeasure()

Measure(Size)

Carries out a measure of the control.

public void Measure(Size availableSize)

Parameters

availableSize Size

The available size for the control.

MeasureCore(Size)

The default implementation of the control's measure pass.

protected virtual Size MeasureCore(Size availableSize)

Parameters

availableSize Size

The size available to the control.

Returns

Size

The desired size for the control.

Remarks

This method calls MeasureOverride(Size) which is probably the method you want to override in order to modify a control's arrangement.

MeasureOverride(Size)

Measures the control and its child elements as part of a layout pass.

protected virtual Size MeasureOverride(Size availableSize)

Parameters

availableSize Size

The size available to the control.

Returns

Size

The desired size for the control.

OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs)

Calls the OnAttachedToVisualTree(VisualTreeAttachmentEventArgs) method for this control and all of its visual descendants.

protected override void OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs e)

Parameters

e VisualTreeAttachmentEventArgs

The event args.

OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs)

Calls the OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs) method for this control and all of its visual descendants.

protected override void OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs e)

Parameters

e VisualTreeAttachmentEventArgs

The event args.

OnMeasureInvalidated()

Called by InvalidateMeasure

protected virtual void OnMeasureInvalidated()

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)

Called when a avalonia property changes on the object.

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)

Parameters

change AvaloniaPropertyChangedEventArgs

The property change details.

OnVisualParentChanged(Visual?, Visual?)

Called when the control's visual parent changes.

protected override sealed void OnVisualParentChanged(Visual? oldParent, Visual? newParent)

Parameters

oldParent Visual

The old visual parent.

newParent Visual

The new visual parent.

UpdateLayout()

Executes a layout pass.

public void UpdateLayout()

Remarks

You should not usually need to call this method explictly, the layout manager will schedule layout passes itself.

Events

EffectiveViewportChanged

Occurs when the element's effective viewport changes.

public event EventHandler<EffectiveViewportChangedEventArgs>? EffectiveViewportChanged

Event Type

EventHandler<EffectiveViewportChangedEventArgs>

LayoutUpdated

Occurs when a layout pass completes for the control.

public event EventHandler? LayoutUpdated

Event Type

EventHandler