Explicitly Defining Columns

If you choose, you can explicitly define columns. If the AutoGenerateColumns property is False only the columns you have defined will appear in the grid.

In Microsoft Expression Blend, you can use the DataGridColumn Collection Editor to define columns in your grid. Select the C1DataGrid control, and in the Properties window select the ellipsis button next to the Columns(Collection) item in the Miscellaneous group. The DataGridColumn Collection Editor dialog box will appear:

You can also define custom columns in the grid in XAML by using the Columns collection.

For example:

XAML
Copy Code
<c1:C1DataGrid x:Name="grid" Grid.Row="1" Grid.ColumnSpan="2" Margin="5" AutoGeneratingColumn="grid_AutoGeneratingColumn" CanUserAddRows="False" ColumnHeaderHeight="30" >
    <c1:C1DataGrid.Columns>
        <!-- 
        Custom check box column.
        Adds a check box to the header and listens to its events.
        -->
        < c1:DataGridCheckBoxColumn Binding="{Binding Available, Mode=TwoWay}" DisplayIndex="0" SortMemberPath="Available" FilterMemberPath="Available" MinWidth="108" >
            < c1:DataGridColumn.Header>
                < StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                    < TextBlock Margin="6,0,6,0" VerticalAlignment="Center" Text="Available"/>
                    < CheckBox HorizontalAlignment="Left" IsHitTestVisible="True" VerticalAlignment="Center" Grid.Column="1" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked" Loaded="CheckBox_Loaded"/>
                < /StackPanel>
            < /c1:DataGridColumn.Header>
        < /c1:DataGridCheckBoxColumn>            
        <!-- 
        Custom "merged" column made with a DataGridTemplateColumn.            
        You can also inherit from DataGridTemplateColumn and set 
        this configuration in the constructor to make your XAML 
        cleaner.
        -->
        < c1:DataGridTemplateColumn>
            < c1:DataGridTemplateColumn.Header>
                < local:MergedColumnEditor ControlMode="Header" />
            < /c1:DataGridTemplateColumn.Header>
            < c1:DataGridTemplateColumn.CellTemplate>
                < DataTemplate>
                    < local:MergedColumnEditor ControlMode="Cell" />
                < /DataTemplate>
            < /c1:DataGridTemplateColumn.CellTemplate>
            < c1:DataGridTemplateColumn.CellEditingTemplate>
                < DataTemplate>
                    < local:MergedColumnEditor ControlMode="EditingCell" />
                < /DataTemplate>
            < /c1:DataGridTemplateColumn.CellEditingTemplate>
        < /c1:DataGridTemplateColumn>
    </c1:C1DataGrid.Columns>
</c1:C1DataGrid>