Export (0) Print
Expand All

DataGridColumn.Width Property

Gets or sets the column width or an automatic sizing mode.

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

public DataGridLength Width { get; set; }
<sdk:dataGridColumn Width="dataGridLengthValue"/>

XAML Values

sdk:dataGridColumn

Typically, sdk:DataGridTextColumn, sdk:DataGridCheckBoxColumn, or sdk:DataGridTemplateColumn.

dataGridLengthValue

A string that specifies a DataGridLength value. This can be an absolute pixel measure, a star sizing, or the constants Auto, SizeToCells, SizeToHeader. For more information, see DataGridLength.

Property Value

Type: System.Windows.Controls.DataGridLength
A structure that represents the column width or an automatic sizing mode. The default is the DataGrid.ColumnWidth property value.

This property overrides the DataGrid.ColumnWidth property.

Version Notes

Silverlight 3: The star sizing feature and using * in XAML are not available for Silverlight 3.

The following code example shows how to set a Width property to the star value.


<sdk:DataGrid x:Name="productDataGrid"  AutoGenerateColumns="False" ItemsSource="{Binding}">
    <sdk:DataGrid.Columns>
        <sdk:DataGridTextColumn Binding="{Binding ID}" />
        <sdk:DataGridTextColumn Binding="{Binding Name}"/>
        <sdk:DataGridTextColumn Binding="{Binding Description}" Width="*" />
        <sdk:DataGridTextColumn Binding="{Binding Price}"/>
    </sdk:DataGrid.Columns>
    </sdk:DataGrid>


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.

Community Additions

ADD
Show:
© 2014 Microsoft