In This Article

LayoutSettings Class

Provides access to layout settings.

public class LayoutSettings : ObservableObjectBase
Inheritance:
object ObservableObjectBase object

Constructors

LayoutSettings()

Initializes an instance of the class.

public LayoutSettings()

Properties

CompactScaleUnit

The scale unit to use for compact user density.

public static int CompactScaleUnit { get; set; }

Property Value

int:

The default value is 4.

Remarks

Although changing this property's default value is generally discouraged, if you do need to override it, make sure to set it during application startup, before any controls are created, to ensure consistent behavior. Its value should be less than the NormalScaleUnit value to maintain the intended density differences between settings.

Instance

The static instance of the LayoutSettings class.

public static LayoutSettings Instance { get; }

Property Value

LayoutSettings

NormalScaleUnit

The scale unit to use for normal user density.

public static int NormalScaleUnit { get; set; }

Property Value

int:

The default value is 6.

Remarks

Although changing this property's default value is generally discouraged, if you do need to override it, make sure to set it during application startup, before any controls are created, to ensure consistent behavior. Its value should be greater than the CompactScaleUnit value and less than the SpaciousScaleUnit value to maintain the intended density differences between settings.

ScaleUnit

The scale unit to apply to spacings.

public double ScaleUnit { get; }

Property Value

double:

The value depends on the current UserInterfaceDensity setting.

SpaciousScaleUnit

The scale unit to use for spacious user density.

public static int SpaciousScaleUnit { get; set; }

Property Value

int:

The default value is 8.

Remarks

Although changing this property's default value is generally discouraged, if you do need to override it, make sure to set it during application startup, before any controls are created, to ensure consistent behavior. Its value should be greater than the NormalScaleUnit value to maintain the intended density differences between settings.

UserInterfaceDensity

The current UserInterfaceDensity that specifies the target density level of user interface elements.

public UserInterfaceDensity UserInterfaceDensity { get; }

Property Value

UserInterfaceDensity

Methods

OnPropertyChanged(PropertyChangedEventArgs)

Raises the PropertyChanged event.

protected override void OnPropertyChanged(PropertyChangedEventArgs e)
Parameter Type Description
e PropertyChangedEventArgs

The event data.

ScaleCornerRadius(double)

Returns a Avalonia.CornerRadius that multiplies a uniform radius factor by the ScaleUnit.

public CornerRadius ScaleCornerRadius(double uniformRadiusFactor)
Parameter Type Description
uniformRadiusFactor double

The uniform radius factor.

Returns

CornerRadius:

The Avalonia.CornerRadius that was created.

ScaleCornerRadius(double, double)

Returns a Avalonia.CornerRadius that multiplies top and bottom radius factors by the ScaleUnit.

public CornerRadius ScaleCornerRadius(double topFactor, double bottomFactor)
Parameter Type Description
topFactor double

The top factor.

bottomFactor double

The bottom factor.

Returns

CornerRadius:

The Avalonia.CornerRadius that was created.

ScaleCornerRadius(double, double, double, double)

Returns a Avalonia.CornerRadius that multiplies corner radius factors by the ScaleUnit.

public CornerRadius ScaleCornerRadius(double topLeftFactor, double topRightFactor, double bottomRightFactor, double bottomLeftFactor)
Parameter Type Description
topLeftFactor double

The top left factor.

topRightFactor double

The top right factor.

bottomRightFactor double

The bottom right factor.

bottomLeftFactor double

The bottom left factor.

Returns

CornerRadius:

The Avalonia.CornerRadius that was created.

ScaleCornerRadius(double, double, double, double, double, double, double, double)

Returns a Avalonia.CornerRadius that multiplies corner radius factors by the ScaleUnit and adds in unscaled adjustments.

public CornerRadius ScaleCornerRadius(double topLeftFactor, double topLeftAdjustment, double topRightFactor, double topRightAdjustment, double bottomRightFactor, double bottomRightAdjustment, double bottomLeftFactor, double bottomLeftAdjustment)
Parameter Type Description
topLeftFactor double

The top left factor.

topLeftAdjustment double

The top left adjustment.

topRightFactor double

The top right factor.

topRightAdjustment double

The top right adjustment.

bottomRightFactor double

The bottom right factor.

bottomRightAdjustment double

The bottom right adjustment.

bottomLeftFactor double

The bottom left factor.

bottomLeftAdjustment double

The bottom left adjustment.

Returns

CornerRadius:

The Avalonia.CornerRadius that was created.

ScaleDouble(double, double?)

Returns a double that multiplies a factor by the ScaleUnit and optionally adds in an unscaled adjustment.

public double ScaleDouble(double factor, double? adjustment = null)
Parameter Type Description
factor double

The factor.

adjustment double?

The optional adjustment.

Returns

double:

The double that was created.

ScaleGridLength(double, double?, bool)

Returns a Avalonia.Controls.GridLength that multiplies a factor by the ScaleUnit and optionally adds in an unscaled adjustment.

public GridLength ScaleGridLength(double factor, double? adjustment = null, bool useStarSizing = false)
Parameter Type Description
factor double

The factor.

adjustment double?

The optional adjustment.

useStarSizing bool

Whether the Avalonia.Controls.GridLength uses star-sizing. The default value is false.

Returns

GridLength:

The Avalonia.Controls.GridLength that was created.

ScaleThickness(double)

Returns a Avalonia.Thickness that multiplies a uniform length factor by the ScaleUnit.

public Thickness ScaleThickness(double uniformLengthFactor)
Parameter Type Description
uniformLengthFactor double

The uniform length factor.

Returns

Thickness:

The Avalonia.Thickness that was created.

ScaleThickness(double, double)

Returns a Avalonia.Thickness that multiplies horizontal and vertical length factors by the ScaleUnit.

public Thickness ScaleThickness(double horizontalFactor, double verticalFactor)
Parameter Type Description
horizontalFactor double

The horizontal factor.

verticalFactor double

The vertical factor.

Returns

Thickness:

The Avalonia.Thickness that was created.

ScaleThickness(double, double, double, double)

Returns a Avalonia.Thickness that multiplies side length factors by the ScaleUnit.

public Thickness ScaleThickness(double leftFactor, double topFactor, double rightFactor, double bottomFactor)
Parameter Type Description
leftFactor double

The left factor.

topFactor double

The top factor.

rightFactor double

The right factor.

bottomFactor double

The bottom factor.

Returns

Thickness:

The Avalonia.Thickness that was created.

ScaleThickness(double, double, double, double, double, double, double, double)

Returns a Avalonia.Thickness that multiplies side length factors by the ScaleUnit and adds in unscaled adjustments.

public Thickness ScaleThickness(double leftFactor, double leftAdjustment, double topFactor, double topAdjustment, double rightFactor, double rightAdjustment, double bottomFactor, double bottomAdjustment)
Parameter Type Description
leftFactor double

The left factor.

leftAdjustment double

The left adjustment.

topFactor double

The top factor.

topAdjustment double

The top adjustment.

rightFactor double

The right factor.

rightAdjustment double

The right adjustment.

bottomFactor double

The bottom factor.

bottomAdjustment double

The bottom adjustment.

Returns

Thickness:

The Avalonia.Thickness that was created.

Events

UserInterfaceDensityChanged

Raised when the UserInterfaceDensity property is changed.

public event EventHandler? UserInterfaceDensityChanged

Event Type

EventHandler

Inherited Members

Extension Methods