System.Windows.Controls Nam ...


.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)
Syntax

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.

Remarks

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.

Examples

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.

XAML
<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>
Inheritance Hierarchy

System..::.Object
  System.Windows..::.DependencyObject
    System.Windows.Controls..::.DataGridColumn
      System.Windows.Controls..::.DataGridBoundColumn
        System.Windows.Controls..::.DataGridCheckBoxColumn
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.
Platforms

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

See Also

Reference

Tags :


Page view tracker