Share via


DataGridColumn.Width Property

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

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)

Syntax

'Declaration
Public Property Width As DataGridLength
public DataGridLength Width { get; set; }
<sdk:dataGridColumn Width="dataGridLengthValue"/>

XAML Values

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.

Remarks

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.

Examples

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>

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.