Struct LayoutSize
Describes how much space a child takes along its container's main axis, expressed in the same
vocabulary a web designer uses in CSS: auto, 260px, 1fr, 30%, with
optional min/max clamps (CSS min-/max-width|height / grid minmax()).
Assembly: Serenity.Ui.Domain.dll
Syntax
Remarks
Fields
HasMax
Whether Max should be applied as an upper clamp (in pixels).
Declaration
Field Value
HasMin
Whether Min should be applied as a lower clamp (in pixels).
Declaration
Field Value
Max
Maximum size in pixels when HasMax is true.
Declaration
Field Value
Min
Minimum size in pixels when HasMin is true.
Declaration
Field Value
Unit
The unit that gives Value its meaning.
Declaration
public LayoutSizeUnit Unit
Field Value
Value
The magnitude, interpreted by Unit: pixels for FIXED,
a weight for FLEX, a 0..100 percentage for
PERCENT, and ignored for AUTO.
Declaration
Field Value
Methods
Auto()
A content-sized child (CSS auto).
Declaration
public static LayoutSize Auto()
Returns
Clamp(float)
Applies the configured Min/Max clamps to a resolved pixel size.
Declaration
public float Clamp(float resolvedPixels)
Parameters
| Type |
Name |
Description |
| float |
resolvedPixels |
A concrete pixel size to clamp.
|
Returns
| Type |
Description |
| float |
The clamped pixel size.
|
Fixed(float)
A child of exactly pixels px (CSS fixed width/height).
Declaration
public static LayoutSize Fixed(float pixels)
Parameters
| Type |
Name |
Description |
| float |
pixels |
|
Returns
Flex(float)
A child taking weight share of leftover space (CSS fr).
Declaration
public static LayoutSize Flex(float weight = 1)
Parameters
| Type |
Name |
Description |
| float |
weight |
|
Returns
Parse(string)
Parses a single CSS-style token into a LayoutSize: auto, 260px,
1fr, or 30%. A bare number is treated as pixels. Useful for grid track lists
and programmatic authoring; min/max are not part of the token grammar.
Declaration
public static LayoutSize Parse(string token)
Parameters
| Type |
Name |
Description |
| string |
token |
The CSS-style size token to parse.
|
Returns
Exceptions
Percent(float)
A child sized to percent (0..100) of the parent's main axis.
Declaration
public static LayoutSize Percent(float percent)
Parameters
| Type |
Name |
Description |
| float |
percent |
|
Returns
ToString()
Returns a CSS-like representation, e.g. 260px, 1fr, 30%, auto.
Declaration
public override string ToString()
Returns
Overrides
WithMax(float)
Returns a copy of this size with a maximum-pixels clamp applied.
Declaration
public LayoutSize WithMax(float max)
Parameters
| Type |
Name |
Description |
| float |
max |
|
Returns
WithMin(float)
Returns a copy of this size with a minimum-pixels clamp applied.
Declaration
public LayoutSize WithMin(float min)
Parameters
| Type |
Name |
Description |
| float |
min |
|
Returns