Struct GridLength
- Namespace
- SharpConsoleUI.Layout
- Assembly
- SharpConsoleUI.dll
A sizing primitive for a grid row or column. Describes whether the track is Fixed (exact cells), Auto (size-to-content), or Star (proportional share of leftover space), with optional minimum and maximum cell clamps.
public readonly struct GridLength
- Inherited Members
- Extension Methods
Remarks
The default value (new GridLength()) is equivalent to
Cells(int, int?, int?) with n = 0: a zero-width
Fixed track. Callers should always construct instances via the
Cells(int, int?, int?), Auto(int?, int?), and
Star(double, int?, int?) factories rather than relying on the default.
Properties
Max
Gets the optional maximum size, in cells, that the track is clamped to.
public int? Max { get; }
Property Value
- int?
Min
Gets the optional minimum size, in cells, that the track is clamped to.
public int? Min { get; }
Property Value
- int?
Type
Gets how the track is sized.
public GridUnitType Type { get; }
Property Value
Value
Gets the exact cell count for a Fixed track.
public int Value { get; }
Property Value
Weight
Gets the relative weight for a Star track.
public double Weight { get; }
Property Value
Methods
Auto(int?, int?)
Creates a Auto track that sizes itself to its content.
public static GridLength Auto(int? min = null, int? max = null)
Parameters
Returns
- GridLength
An auto-sized GridLength.
Exceptions
- ArgumentOutOfRangeException
Thrown when both
minandmaxare specified andminis greater thanmax.
Cells(int, int?, int?)
Creates a Fixed track of exactly n cells.
public static GridLength Cells(int n, int? min = null, int? max = null)
Parameters
nintThe exact size of the track, in cells.
minint?An optional minimum size, in cells.
maxint?An optional maximum size, in cells.
Returns
- GridLength
A fixed-size GridLength.
Exceptions
- ArgumentOutOfRangeException
Thrown when both
minandmaxare specified andminis greater thanmax.
Star(double, int?, int?)
Creates a Star track that takes a proportional share of the
leftover space, based on weight.
public static GridLength Star(double weight = 1, int? min = null, int? max = null)
Parameters
weightdoubleThe relative weight of the track. Values of 0 or less default to 1.
minint?An optional minimum size, in cells.
maxint?An optional maximum size, in cells.
Returns
- GridLength
A proportionally-sized GridLength.
Exceptions
- ArgumentOutOfRangeException
Thrown when both
minandmaxare specified andminis greater thanmax.