GridLength Structure
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Represents the length of elements that explicitly support Star unit types.
Assembly: System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
The GridLength type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | GridLength(Double) | Initializes a new instance of the GridLength structure using the specified absolute value in logical pixels. |
![]() | GridLength(Double, GridUnitType) | Initializes a new instance of the GridLength structure and specifies what kind of value it holds. |
| Name | Description | |
|---|---|---|
![]() ![]() | Auto | Gets an instance of GridLength that holds a value whose size is determined by the size properties of the content object. |
![]() | GridUnitType | Gets the associated GridUnitType for the GridLength. |
![]() | IsAbsolute | Gets a value that indicates whether the GridLength holds a value that is expressed in logical pixels. |
![]() | IsAuto | Gets a value that indicates whether the GridLength holds a value whose size is determined by the size properties of the content object. |
![]() | IsStar | Gets a value that indicates whether the GridLength holds a value that is expressed as a weighted proportion of available space. |
![]() | Value | Gets a Double that represents the value of the GridLength. |
| Name | Description | |
|---|---|---|
![]() | Equals(GridLength) | Determines whether the specified GridLength is equal to the current GridLength. |
![]() | Equals(Object) | Determines whether the specified object is equal to the current GridLength instance. (Overrides ValueType::Equals(Object).) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Gets a hash code for the GridLength. (Overrides ValueType::GetHashCode().) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a String representation of the GridLength. (Overrides ValueType::ToString().) |
| Name | Description | |
|---|---|---|
![]() ![]() | Equality | Compares two GridLength structures for equality. |
![]() ![]() | Inequality | Compares two GridLength structures to determine if they are not equal. |
Elements such as ColumnDefinition and RowDefinition use this type to describe width and height in order to support variable distribution of available space.
If you specify a GridLength for use as a resource, use the object element usage and set the GridLength value using initialization text.
Star Sizing
Star sizing is a convention whereby any GridLength measurement that includes an asterisk (*) in its XAML-declared value uses any remaining space for rows or columns. * can be preceded with a number value that specifies a weighted factor versus other possible star sizings (for example, 3*). If all GridLength values that declare rows or columns use star sizing, the space is divided equally, but with any number weights factored in.
The following table provides some examples of star sizing results. For these examples, assume that the parent Grid has a fixed Width of 300, and that these values apply to the Width of three ColumnDefinition elements.
Column 0 | Column 1 | Column 2 | Result |
|---|---|---|---|
50 | 50 | * | 50,50,200 |
50 | * | * | 50,125,125 |
* | 2* | 3* | 50,100,150 |
50 | * | 4* | 50,50,200 |
In code, a star sizing is equivalent to a GridLength where GridLength::IsStar is true, GridLength::GridUnitType is Star, and GridLength::Value is the weighted factor applied, if any (GridLength::Value is 1 for *).
Noninteger numeric factors are allowed, for example .5*.




