Table of Contents

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

GridUnitType

Value

Gets the exact cell count for a Fixed track.

public int Value { get; }

Property Value

int

Weight

Gets the relative weight for a Star track.

public double Weight { get; }

Property Value

double

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

min int?

An optional minimum size, in cells.

max int?

An optional maximum size, in cells.

Returns

GridLength

An auto-sized GridLength.

Exceptions

ArgumentOutOfRangeException

Thrown when both min and max are specified and min is greater than max.

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

n int

The exact size of the track, in cells.

min int?

An optional minimum size, in cells.

max int?

An optional maximum size, in cells.

Returns

GridLength

A fixed-size GridLength.

Exceptions

ArgumentOutOfRangeException

Thrown when both min and max are specified and min is greater than max.

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

weight double

The relative weight of the track. Values of 0 or less default to 1.

min int?

An optional minimum size, in cells.

max int?

An optional maximum size, in cells.

Returns

GridLength

A proportionally-sized GridLength.

Exceptions

ArgumentOutOfRangeException

Thrown when both min and max are specified and min is greater than max.