Table of Contents

Struct GridLength

Namespace
Icy.UI.Controls
Assembly
IcyUI.dll

Specifies the size of a Grid row or column.

public readonly record struct GridLength : IParsable<GridLength>, IEquatable<GridLength>
Implements
Inherited Members
Extension Methods

Constructors

GridLength(float, GridUnitType)

Specifies the size of a Grid row or column.

public GridLength(float Value, GridUnitType UnitType)

Parameters

Value float

The size, interpreted per UnitType - pixels for Pixel, a proportional weight for Star, or ignored for Auto.

UnitType GridUnitType

How Value should be interpreted.

Properties

Auto

Gets a GridLength that sizes to the largest desired size among the track's children.

public static GridLength Auto { get; }

Property Value

GridLength

Star

Gets a GridLength that takes an equal (weight 1) proportional share of remaining space.

public static GridLength Star { get; }

Property Value

GridLength

UnitType

How Value should be interpreted.

public GridUnitType UnitType { get; init; }

Property Value

GridUnitType

Value

The size, interpreted per UnitType - pixels for Pixel, a proportional weight for Star, or ignored for Auto.

public float Value { get; init; }

Property Value

float

Methods

Parse(string, IFormatProvider?)

Parses a track size written the way markup writes it.

public static GridLength Parse(string s, IFormatProvider? provider)

Parameters

s string

Auto, , a star weight such as 2, or a pixel count such as 24. Case-insensitive for Auto.

provider IFormatProvider

The format provider used for the numeric part.

Returns

GridLength

The parsed track size.

Remarks

Implementing IParsable<TSelf> is what lets TypeConversionManager - and therefore markup - turn Width="*" into a value with no bespoke converter registration.

Exceptions

FormatException

s is none of the accepted forms.

StarWeighted(float)

Creates a GridLength that takes a proportional share of remaining space, weighted relative to other Star tracks.

public static GridLength StarWeighted(float weight)

Parameters

weight float

The proportional weight.

Returns

GridLength

A Star GridLength with the given weight.

TryParse(string?, IFormatProvider?, out GridLength)

Attempts to parse a track size written the way markup writes it.

public static bool TryParse(string? s, IFormatProvider? provider, out GridLength result)

Parameters

s string

Auto, , a star weight such as 2, or a pixel count such as 24.

provider IFormatProvider

The format provider used for the numeric part.

result GridLength

The parsed track size, or the default value when parsing failed.

Returns

bool

true when s was parsed.

Operators

implicit operator GridLength(float)

Implicitly converts a pixel size to a fixed GridLength.

public static implicit operator GridLength(float pixels)

Parameters

pixels float

The fixed size, in pixels.

Returns

GridLength