Click to Rate and Give Feedback

  Switch on low bandwidth view
This page is specific to
Microsoft Silverlight 3

Other versions are also available for the following:
.NET Framework Class Library for Silverlight
DataGridCheckBoxColumn Class

Represents a DataGrid column that hosts CheckBox controls in its cells.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Data (in System.Windows.Controls.Data.dll)
Visual Basic (Declaration)
<StyleTypedPropertyAttribute(Property := "EditingElementStyle", StyleTargetType := GetType(CheckBox))> _
<StyleTypedPropertyAttribute(Property := "ElementStyle", StyleTargetType := GetType(CheckBox))> _
Public Class DataGridCheckBoxColumn _
    Inherits DataGridBoundColumn
Visual Basic (Usage)
Dim instance As DataGridCheckBoxColumn
C#
[StyleTypedPropertyAttribute(Property = "EditingElementStyle", StyleTargetType = typeof(CheckBox))]
[StyleTypedPropertyAttribute(Property = "ElementStyle", StyleTargetType = typeof(CheckBox))]
public class DataGridCheckBoxColumn : DataGridBoundColumn
XAML Object Element Usage
<data:DataGridCheckBoxColumn />

XAML Values

data:

A prefix that is defined to map the XML namespace for the System.Windows.Controls.Data assembly and the System.Windows.Controls CLR namespace.

By default, the DataGrid control generates columns automatically when you set the ItemsSource property. The generated columns are of type DataGridCheckBoxColumn for bound Boolean (and nullable Boolean) properties, and of type DataGridTextColumn for all other properties.

The following code example demonstrates how to specify and configure a DataGridCheckBoxColumn in XAML. This example is part of a larger example available in the DataGrid class overview.

<data:DataGrid x:Name="dataGrid4" 
    Height="160" Margin="0,5,0,10" 
    RowHeight="40" AutoGenerateColumns="False" >    
    <data:DataGrid.Columns>
        <data:DataGridTextColumn 
            Header="First Name" 
            Width="SizeToHeader"
            Binding="{Binding FirstName}" 
            FontSize="20" />
        <data:DataGridTextColumn 
            Header="Last Name" 
            Width="SizeToCells"
            Binding="{Binding LastName}" 
            FontSize="20" />
        <data:DataGridTextColumn 
            Header="Address"
            Width="150"
            Binding="{Binding Address}" >
            <data:DataGridTextColumn.ElementStyle>
                <Style TargetType="TextBlock">
                    <Setter Property="TextWrapping" Value="Wrap"/>
                </Style>
            </data:DataGridTextColumn.ElementStyle>
            <data:DataGridTextColumn.EditingElementStyle>
                <Style TargetType="TextBox">
                    <Setter Property="Foreground" Value="Blue"/>
                </Style>
            </data:DataGridTextColumn.EditingElementStyle>
        </data:DataGridTextColumn>
        <data:DataGridCheckBoxColumn 
            Header="New?" 
            Width="40"
            Binding="{Binding IsNew}" />
        <data:DataGridCheckBoxColumn 
            Header="Subscribed?" 
            Width="Auto"
            Binding="{Binding IsSubscribed}" 
            IsThreeState="True" />
    </data:DataGrid.Columns>
</data:DataGrid>

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

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

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker