Table of Contents

Struct MagnetSizing

Namespace
Nalu
Assembly
Nalu.Maui.Layouts.dll

The size of a MagnetView along one axis.

[TypeConverter(typeof(MagnetSizingTypeConverter))]
public readonly record struct MagnetSizing : IEquatable<MagnetSizing>
Implements
Inherited Members

Remarks

XAML: "48" (fixed dp), "50%" (fraction of the anchor span), "*" (fills the anchor span); every other unit and the bounds use the markup extension: {nalu:MagnetSizing 1.5, Unit=Ratio}, {nalu:MagnetSizing 0.5, Unit=StagePercent}, {nalu:MagnetSizing Unit=Constraint, Max=320}.

Constructors

MagnetSizing(MagnetSizingUnit, double, double, double)

The size of a MagnetView along one axis.

public MagnetSizing(MagnetSizingUnit Unit, double Value = 0, double Min = 0, double Max = Infinity)

Parameters

Unit MagnetSizingUnit

How the size is resolved.

Value double

The fixed size, the percent fraction (0..1) or the ratio, depending on Unit.

Min double

Minimum size (applied to every unit).

Max double

Maximum size (applied to every unit; also used as an upper measure constraint for Measured).

Remarks

XAML: "48" (fixed dp), "50%" (fraction of the anchor span), "*" (fills the anchor span); every other unit and the bounds use the markup extension: {nalu:MagnetSizing 1.5, Unit=Ratio}, {nalu:MagnetSizing 0.5, Unit=StagePercent}, {nalu:MagnetSizing Unit=Constraint, Max=320}.

Fields

Constraint

Fills the space between the two anchors of the axis.

public static readonly MagnetSizing Constraint

Field Value

MagnetSizing

Measured

The default size: the measured size of the view.

public static readonly MagnetSizing Measured

Field Value

MagnetSizing

Properties

HasBounds

Gets whether the size has an explicit minimum or maximum.

public bool HasBounds { get; }

Property Value

bool

Max

Maximum size (applied to every unit; also used as an upper measure constraint for Measured).

public double Max { get; init; }

Property Value

double

Min

Minimum size (applied to every unit).

public double Min { get; init; }

Property Value

double

Unit

How the size is resolved.

public MagnetSizingUnit Unit { get; init; }

Property Value

MagnetSizingUnit

Value

The fixed size, the percent fraction (0..1) or the ratio, depending on Unit.

public double Value { get; init; }

Property Value

double

Methods

DiffWith(in MagnetSizing)

Classifies the difference between this size and other.

public MagnetChange DiffWith(in MagnetSizing other)

Parameters

other MagnetSizing

Returns

MagnetChange

Fixed(double)

A fixed size.

public static MagnetSizing Fixed(double value)

Parameters

value double

Returns

MagnetSizing

Parse(string)

Parses the string representation of a size: "48" (fixed dp), "50%" (fraction of the anchor span) or "*" (fills the anchor span). Every other unit is expressed with the struct ({nalu:MagnetSizing 1.5, Unit=Ratio}).

public static MagnetSizing Parse(string value)

Parameters

value string

Returns

MagnetSizing

Percent(double)

A fraction (0..1) of the space between the two anchors of the axis.

public static MagnetSizing Percent(double fraction)

Parameters

fraction double

Returns

MagnetSizing

Ratio(double)

A ratio relative to the other axis size.

public static MagnetSizing Ratio(double ratio)

Parameters

ratio double

Returns

MagnetSizing

Scaled(double)

The measured size multiplied by scale.

public static MagnetSizing Scaled(double scale)

Parameters

scale double

Returns

MagnetSizing

StagePercent(double)

A fraction (0..1) of the stage size on the same axis, regardless of the anchors.

public static MagnetSizing StagePercent(double fraction)

Parameters

fraction double

Returns

MagnetSizing

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

WithBounds(double, double)

Returns a copy with the given bounds.

public MagnetSizing WithBounds(double min = 0, double max = Infinity)

Parameters

min double
max double

Returns

MagnetSizing

Operators

implicit operator MagnetSizing(double)

Implicitly converts a number to a fixed size.

public static implicit operator MagnetSizing(double value)

Parameters

value double

Returns

MagnetSizing

implicit operator MagnetSizing(string)

Implicitly parses the XAML representation of a size.

public static implicit operator MagnetSizing(string value)

Parameters

value string

Returns

MagnetSizing