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
UnitMagnetSizingUnitHow the size is resolved.
ValuedoubleThe fixed size, the percent fraction (0..1) or the ratio, depending on
Unit.MindoubleMinimum size (applied to every unit).
MaxdoubleMaximum 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
Measured
The default size: the measured size of the view.
public static readonly MagnetSizing Measured
Field Value
Properties
HasBounds
Gets whether the size has an explicit minimum or maximum.
public bool HasBounds { get; }
Property Value
Max
Maximum size (applied to every unit; also used as an upper measure constraint for Measured).
public double Max { get; init; }
Property Value
Min
Minimum size (applied to every unit).
public double Min { get; init; }
Property Value
Unit
How the size is resolved.
public MagnetSizingUnit Unit { get; init; }
Property Value
Value
The fixed size, the percent fraction (0..1) or the ratio, depending on Unit.
public double Value { get; init; }
Property Value
Methods
DiffWith(in MagnetSizing)
Classifies the difference between this size and other.
public MagnetChange DiffWith(in MagnetSizing other)
Parameters
otherMagnetSizing
Returns
Fixed(double)
A fixed size.
public static MagnetSizing Fixed(double value)
Parameters
valuedouble
Returns
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
valuestring
Returns
Percent(double)
A fraction (0..1) of the space between the two anchors of the axis.
public static MagnetSizing Percent(double fraction)
Parameters
fractiondouble
Returns
Ratio(double)
A ratio relative to the other axis size.
public static MagnetSizing Ratio(double ratio)
Parameters
ratiodouble
Returns
Scaled(double)
The measured size multiplied by scale.
public static MagnetSizing Scaled(double scale)
Parameters
scaledouble
Returns
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
fractiondouble
Returns
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
Returns
Operators
implicit operator MagnetSizing(double)
Implicitly converts a number to a fixed size.
public static implicit operator MagnetSizing(double value)
Parameters
valuedouble
Returns
implicit operator MagnetSizing(string)
Implicitly parses the XAML representation of a size.
public static implicit operator MagnetSizing(string value)
Parameters
valuestring