Export (0) Print
Expand All

DataGridLength Structure

Represents the lengths of elements within the DataGrid control.

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

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

  NameDescription
Public methodDataGridLength(Double)Initializes a new instance of the DataGridLength class.
Public methodDataGridLength(Double, DataGridLengthUnitType)Initializes a new instance of the DataGridLength class with the specified value and unit type.
Public methodDataGridLength(Double, DataGridLengthUnitType, Double, Double)Initializes a new instance of the DataGridLength class with the specified value, unit type, desired value, and display value.
Top

  NameDescription
Public propertyStatic memberAutoGets a DataGridLength structure that represents the standard automatic sizing mode.
Public propertyDesiredValueThe desired value of the DataGridLength if it is not affected by interactions with other DataGrid columns.
Public propertyDisplayValueGets the actual value for a DataGridLength, in pixels.
Public propertyIsAbsoluteGets a value that indicates whether this DataGridLength instance holds an absolute value.
Public propertyIsAutoGets a value that indicates whether this DataGridLength instance uses the standard automatic sizing mode.
Public propertyIsSizeToCellsGets a value that indicates whether this DataGridLength instance uses the cell-based automatic sizing mode.
Public propertyIsSizeToHeaderGets a value that indicates whether this DataGridLength instance uses the header-based automatic sizing mode.
Public propertyIsStarGets a value that indicates whether UnitType property is set to Star, which means space is distributed by weighted proportion
Public propertyStatic memberSizeToCellsGets a DataGridLength structure that represents the cell-based automatic sizing mode.
Public propertyStatic memberSizeToHeaderGets a DataGridLength structure that represents the header-based automatic sizing mode.
Public propertyUnitTypeGets a value that indicates how the size of the associated DataGrid element is calculated.
Public propertyValueGets the absolute value of the DataGridLength in pixels.
Top

  NameDescription
Public methodEquals(DataGridLength)Determines whether the specified DataGridLength is equal to the current DataGridLength.
Public methodEquals(Object)Determines whether the specified object is equal to the current DataGridLength. (Overrides ValueType.Equals(Object).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeGets a hash code for the DataGridLength. (Overrides ValueType.GetHashCode().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns the fully qualified type name of this instance. (Inherited from ValueType.)
Top

  NameDescription
Public operatorStatic memberEqualityCompares two DataGridLength structures for equality.
Public operatorStatic memberInequalityCompares two DataGridLength structures to determine whether they are not equal.
Top

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.

Silverlight

Supported in: 5, 4, 3

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

ADD
Show:
© 2014 Microsoft