Table of Contents

Class LayoutHelper

Namespace
Avalonia.Layout
Assembly
Avalonia.Base.dll

Provides helper methods needed for layout.

public static class LayoutHelper
Inheritance
LayoutHelper
Inherited Members

Properties

LayoutEpsilon

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

public static double LayoutEpsilon { get; }

Property Value

double

Methods

ApplyLayoutConstraints(Layoutable, Size)

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

public static Size ApplyLayoutConstraints(Layoutable control, Size constraints)

Parameters

control Layoutable

The control.

constraints Size

The space available for the control.

Returns

Size

The control's size.

ArrangeChild(Layoutable?, Size, Thickness)

public static Size ArrangeChild(Layoutable? child, Size availableSize, Thickness padding)

Parameters

child Layoutable
availableSize Size
padding Thickness

Returns

Size

ArrangeChild(Layoutable?, Size, Thickness, Thickness)

public static Size ArrangeChild(Layoutable? child, Size availableSize, Thickness padding, Thickness borderThickness)

Parameters

child Layoutable
availableSize Size
padding Thickness
borderThickness Thickness

Returns

Size

GetLayoutScale(Layoutable)

Obtains layout scale of the given control.

public static double GetLayoutScale(Layoutable control)

Parameters

control Layoutable

The control.

Returns

double

Exceptions

Exception

Thrown when control has no root or returned layout scaling is invalid.

InvalidateSelfAndChildrenMeasure(Layoutable)

Invalidates measure for given control and all visual children recursively.

public static void InvalidateSelfAndChildrenMeasure(Layoutable control)

Parameters

control Layoutable

MeasureChild(Layoutable?, Size, Thickness)

public static Size MeasureChild(Layoutable? control, Size availableSize, Thickness padding)

Parameters

control Layoutable
availableSize Size
padding Thickness

Returns

Size

MeasureChild(Layoutable?, Size, Thickness, Thickness)

public static Size MeasureChild(Layoutable? control, Size availableSize, Thickness padding, Thickness borderThickness)

Parameters

control Layoutable
availableSize Size
padding Thickness
borderThickness Thickness

Returns

Size

RoundLayoutSizeUp(Size, double, double)

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 static Size RoundLayoutSizeUp(Size size, double dpiScaleX, double dpiScaleY)

Parameters

size Size

Input size.

dpiScaleX double

DPI along x-dimension.

dpiScaleY double

DPI along y-dimension.

Returns

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(Thickness, double, double)

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

public static Thickness RoundLayoutThickness(Thickness thickness, double dpiScaleX, double dpiScaleY)

Parameters

thickness Thickness

Input thickness.

dpiScaleX double

DPI along x-dimension.

dpiScaleY double

DPI along y-dimension.

Returns

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(double, double)

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

public static 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(double, double)

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

public static 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.