DataGridLength Structure

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Represents the lengths of elements within the DataGrid control.

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

Syntax

'Declaration
<TypeConverterAttribute(GetType(DataGridLengthConverter))> _
Public Structure DataGridLength _
    Implements IEquatable(Of DataGridLength)
[TypeConverterAttribute(typeof(DataGridLengthConverter))]
public struct DataGridLength : IEquatable<DataGridLength>
<object property="absolutePixelValue"/>
- or -
<object property="starSizing"/>
- or -
<object property="Auto"/>
- or -
<object property="SizeToCells"/>
- or -
<object property="SizeToHeader"/>

XAML Values

  • absolutePixelValue
    A positive numeric value for the absolute width of a column.

  • starSizing
    A string token that includes the * literal character, optionally preceded by a numeric factor. For example, 3*. Not usable in Silverlight 3. See Remarks.

  • Auto
    Literal string value that enables Auto sizing, which sizes DataGrid columns based on the contents of both cells and column headers.

  • SizeToCells
    Literal string value that enables SizeToCells sizing, which sizes DataGrid columns based on the contents of cells in the column, not including column headers.

  • SizeToHeader
    Literal string value that enables SizeToHeader sizing, which sizes DataGrid columns based on the contents of column headers only.

  • *
    Literal string value that indicates width is a weighted proportion of the remaining space.

The DataGridLength type exposes the following members.

Constructors

  Name Description
Public method DataGridLength(Double) Initializes a new instance of the DataGridLength class.
Public method DataGridLength(Double, DataGridLengthUnitType) Initializes a new instance of the DataGridLength class with the specified value and unit type.
Public method DataGridLength(Double, DataGridLengthUnitType, Double, Double) Initializes a new instance of the DataGridLength class with the specified value, unit type, desired value, and display value.

Top

Properties

  Name Description
Public propertyStatic member Auto Gets a DataGridLength structure that represents the standard automatic sizing mode.
Public property DesiredValue The desired value of the DataGridLength if it is not affected by interactions with other DataGrid columns.
Public property DisplayValue Gets the actual value for a DataGridLength, in pixels.
Public property IsAbsolute Gets a value that indicates whether this DataGridLength instance holds an absolute value.
Public property IsAuto Gets a value that indicates whether this DataGridLength instance uses the standard automatic sizing mode.
Public property IsSizeToCells Gets a value that indicates whether this DataGridLength instance uses the cell-based automatic sizing mode.
Public property IsSizeToHeader Gets a value that indicates whether this DataGridLength instance uses the header-based automatic sizing mode.
Public property IsStar Gets a value that indicates whether UnitType property is set to Star, which means space is distributed by weighted proportion
Public propertyStatic member SizeToCells Gets a DataGridLength structure that represents the cell-based automatic sizing mode.
Public propertyStatic member SizeToHeader Gets a DataGridLength structure that represents the header-based automatic sizing mode.
Public property UnitType Gets a value that indicates how the size of the associated DataGrid element is calculated.
Public property Value Gets the absolute value of the DataGridLength in pixels.

Top

Methods

  Name Description
Public method Equals(DataGridLength) Determines whether the specified DataGridLength is equal to the current DataGridLength.
Public method Equals(Object) Determines whether the specified object is equal to the current DataGridLength. (Overrides ValueType.Equals(Object).)
Protected method 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.)
Public method GetHashCode Gets a hash code for the DataGridLength. (Overrides ValueType.GetHashCode().)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns the fully qualified type name of this instance. (Inherited from ValueType.)

Top

Operators

  Name Description
Public operatorStatic member Equality Compares two DataGridLength structures for equality.
Public operatorStatic member Inequality Compares two DataGridLength structures to determine whether they are not equal.

Top

Remarks

The DataGridLength type is used by the DataGridColumn.Width and DataGrid.ColumnWidth properties to enable you to specify absolute values or automatic sizing modes.

In Silverlight 4 and later, the star sizing mode can be used to distribute available space by weighted proportions.

In Extensible Application Markup Language (XAML), star sizing values are expressed as n* where n represents a numeric value. 1* is equivalent to *. Any width that uses star sizing divides any remaining width in the DataGrid container. For example if two columns in a DataGrid had widths of * and 2*, the first column would receive one portion of the available space and the second column would receive two portions of the available space. As another example, if a DataGrid had a fixed width of 800, and column widths of 200, * and 2*, the widths of the three columns would be 200, 200, and 400. For more information, see Sizing Options in the DataGrid Control.

DataGridLength structures can be declared as resources in a ResourceDictionary, if you use an initialization text form that invokes the same string type conversion behavior as the attribute form.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

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

Thread Safety

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