Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

GridLength Structure

Represents the length of elements that explicitly support Star unit types.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

public struct GridLength
<GridLength ...>doubleValue</GridLength>
- or -
<GridLength ...>starSizing</GridLength>
- or -
<GridLength ...>Auto</GridLength>
<object property="doubleValue"/>
- or -
<object property="starSizing"/>
-or-
<object property="Auto"/>

XAML Values

doubleValue

The row's height, or column's width, expressed as a floating-point value for a pixel count. Typically this is specified as an integer, although interpolation of floating-point values is supported by grid layout.

starSizing

A string that includes the * character. Sizes rows or columns to take the remaining available space in a Grid. See the "Star Sizing" section in Remarks,

Auto

The column's width, or the row's height, described by the literal Auto. For more information about Auto sizing, see Grid.

The GridLength type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneGridLength(Double)Initializes a new instance of the GridLength structure using the specified absolute value in pixels.
Public methodSupported by Silverlight for Windows PhoneGridLength(Double, GridUnitType)Initializes a new instance of the GridLength structure and specifies what kind of value it holds.
Top

  NameDescription
Public propertyStatic memberSupported by Silverlight for Windows PhoneAutoGets an instance of GridLength that holds a value whose size is determined by the size properties of the content object.
Public propertySupported by Silverlight for Windows PhoneGridUnitTypeGets the associated GridUnitType for the GridLength.
Public propertySupported by Silverlight for Windows PhoneIsAbsoluteGets a value that indicates whether the GridLength holds a value that is expressed in pixels.
Public propertySupported by Silverlight for Windows PhoneIsAutoGets a value that indicates whether the GridLength holds a value whose size is determined by the size properties of the content object.
Public propertySupported by Silverlight for Windows PhoneIsStarGets a value that indicates whether the GridLength holds a value that is expressed as a weighted proportion of available space.
Public propertySupported by Silverlight for Windows PhoneValueGets a Double that represents the value of the GridLength.
Top

  NameDescription
Public methodSupported by Silverlight for Windows PhoneEquals(GridLength)Determines whether the specified GridLength is equal to the current GridLength.
Public methodSupported by Silverlight for Windows PhoneEquals(Object)Determines whether the specified object is equal to the current GridLength instance. (Overrides ValueType.Equals(Object).)
Protected methodSupported by Silverlight for Windows PhoneFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetHashCodeGets a hash code for the GridLength. (Overrides ValueType.GetHashCode().)
Public methodSupported by Silverlight for Windows PhoneGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneToStringReturns a String representation of the GridLength. (Overrides ValueType.ToString().)
Top

  NameDescription
Public operatorStatic memberSupported by Silverlight for Windows PhoneEqualityCompares two GridLength structures for equality.
Public operatorStatic memberSupported by Silverlight for Windows PhoneInequalityCompares two GridLength structures to determine if they are not equal.
Top

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 600, and that these values apply to the Width of three ColumnDefinition elements.

Column 0

Column 1

Column 2

Result

100

100

*

100,100,400

100

*

*

100,250,250

*

2*

3*

100,200,300

100

*

4*

100,100,400

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*.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

Show:
© 2014 Microsoft