Skip to main content

LayoutHelper Class

Definition​

Namespace:Avalonia.Layout
Assembly:Avalonia.Base
Package:Avalonia

Provides helper methods needed for layout.

public class LayoutHelper

Inheritance: object -> LayoutHelper

Methods​

NameDescription
ApplyLayoutConstraintsCalculates a control's size based on its Avalonia.Layout.Layoutable.Width, Avalonia.Layout.Layoutable.Height, Avalonia.Layout.Layoutable.MinWidth, Avalonia.Layout.Layoutable.MaxWidth, Avalonia.Layout.Layoutable.MinHeight and Avalonia.Layout.Layoutable.MaxHeight.
ArrangeChild (2 overloads)No summary available.
GetLayoutScaleObtains layout scale of the given control.
InvalidateSelfAndChildrenMeasureInvalidates measure for given control and all visual children recursively.
MeasureChild (2 overloads)No summary available.
RoundLayoutPointNo summary available.
RoundLayoutSizeUpRounds a size to integer values for layout purposes, compensating for high DPI screen coordinates by rounding the size up to the nearest pixel.
RoundLayoutThicknessRounds a thickness to integer values for layout purposes, compensating for high DPI screen coordinates.
RoundLayoutValueCalculates the value to be used for layout rounding at high DPI by rounding the value up or down to the nearest pixel.
RoundLayoutValueUpCalculates the value to be used for layout rounding at high DPI by rounding the value up to the nearest pixel.

ApplyLayoutConstraints Method​

Calculates a control's size based on its Avalonia.Layout.Layoutable.Width, Avalonia.Layout.Layoutable.Height, Avalonia.Layout.Layoutable.MinWidth, Avalonia.Layout.Layoutable.MaxWidth, Avalonia.Layout.Layoutable.MinHeight and Avalonia.Layout.Layoutable.MaxHeight.

public Avalonia.Size ApplyLayoutConstraints(Avalonia.Layout.Layoutable control, Avalonia.Size constraints)

Parameters​

control Avalonia.Layout.Layoutable

The control.

constraints Avalonia.Size

The space available for the control.

Returns​

Avalonia.Size

The control's size.

ArrangeChild overloads​

ArrangeChild Method​

public Avalonia.Size ArrangeChild(Avalonia.Layout.Layoutable child, Avalonia.Size availableSize, Avalonia.Thickness padding)
Parameters​

child Avalonia.Layout.Layoutable

availableSize Avalonia.Size

padding Avalonia.Thickness

Returns​

Avalonia.Size

ArrangeChild Method​

public Avalonia.Size ArrangeChild(Avalonia.Layout.Layoutable child, Avalonia.Size availableSize, Avalonia.Thickness padding, Avalonia.Thickness borderThickness)
Parameters​

child Avalonia.Layout.Layoutable

availableSize Avalonia.Size

padding Avalonia.Thickness

borderThickness Avalonia.Thickness

Returns​

Avalonia.Size

GetLayoutScale Method​

Obtains layout scale of the given control.

public double GetLayoutScale(Avalonia.Layout.Layoutable control)

Parameters​

control Avalonia.Layout.Layoutable

The control.

Returns​

double

Exceptions​

InvalidateSelfAndChildrenMeasure Method​

Invalidates measure for given control and all visual children recursively.

public void InvalidateSelfAndChildrenMeasure(Avalonia.Layout.Layoutable control)

Parameters​

control Avalonia.Layout.Layoutable

MeasureChild overloads​

MeasureChild Method​

public Avalonia.Size MeasureChild(Avalonia.Layout.Layoutable control, Avalonia.Size availableSize, Avalonia.Thickness padding)
Parameters​

control Avalonia.Layout.Layoutable

availableSize Avalonia.Size

padding Avalonia.Thickness

Returns​

Avalonia.Size

MeasureChild Method​

public Avalonia.Size MeasureChild(Avalonia.Layout.Layoutable control, Avalonia.Size availableSize, Avalonia.Thickness padding, Avalonia.Thickness borderThickness)
Parameters​

control Avalonia.Layout.Layoutable

availableSize Avalonia.Size

padding Avalonia.Thickness

borderThickness Avalonia.Thickness

Returns​

Avalonia.Size

RoundLayoutPoint Method​

public Avalonia.Point RoundLayoutPoint(Avalonia.Point point, double dpiScale)

Parameters​

point Avalonia.Point

dpiScale double

Returns​

Avalonia.Point

RoundLayoutSizeUp Method​

Rounds a size to integer values for layout purposes, compensating for high DPI screen coordinates by rounding the size up to the nearest pixel.

public Avalonia.Size RoundLayoutSizeUp(Avalonia.Size size, double dpiScale)

Parameters​

size Avalonia.Size

Input size.

dpiScale double

The DPI scale.

Returns​

Avalonia.Size

Value of size that will be rounded under screen DPI.

Remarks​

This is a layout helper method. It takes DPI into account and also does not return the rounded value if it is unacceptable for layout, e.g. Infinity or NaN. It's a helper associated with the UseLayoutRounding property and should not be used as a general rounding utility.

RoundLayoutThickness Method​

Rounds a thickness to integer values for layout purposes, compensating for high DPI screen coordinates.

public Avalonia.Thickness RoundLayoutThickness(Avalonia.Thickness thickness, double dpiScale)

Parameters​

thickness Avalonia.Thickness

Input thickness.

dpiScale double

The DPI scale.

Returns​

Avalonia.Thickness

Value of thickness that will be rounded under screen DPI.

Remarks​

This is a layout helper method. It takes DPI into account and also does not return the rounded value if it is unacceptable for layout, e.g. Infinity or NaN. It's a helper associated with the UseLayoutRounding property and should not be used as a general rounding utility.

RoundLayoutValue Method​

Calculates the value to be used for layout rounding at high DPI by rounding the value up or down to the nearest pixel.

public double RoundLayoutValue(double value, double dpiScale)

Parameters​

value double

Input value to be rounded.

dpiScale double

Ratio of screen's DPI to layout DPI

Returns​

double

Adjusted value that will produce layout rounding on screen at high dpi.

Remarks​

This is a layout helper method. It takes DPI into account and also does not return the rounded value if it is unacceptable for layout, e.g. Infinity or NaN. It's a helper associated with the UseLayoutRounding property and should not be used as a general rounding utility.

RoundLayoutValueUp Method​

Calculates the value to be used for layout rounding at high DPI by rounding the value up to the nearest pixel.

public double RoundLayoutValueUp(double value, double dpiScale)

Parameters​

value double

Input value to be rounded.

dpiScale double

Ratio of screen's DPI to layout DPI

Returns​

double

Adjusted value that will produce layout rounding on screen at high dpi.

Remarks​

This is a layout helper method. It takes DPI into account and also does not return the rounded value if it is unacceptable for layout, e.g. Infinity or NaN. It's a helper associated with the UseLayoutRounding property and should not be used as a general rounding utility.

Properties​

NameDescription
LayoutEpsilonEpsilon value used for certain layout calculations. Based on the value in WPF LayoutDoubleUtil.

LayoutEpsilon Property​

Epsilon value used for certain layout calculations. Based on the value in WPF LayoutDoubleUtil.

public double LayoutEpsilon { get; set; }