<UserControl x:Class="DataGridSamples.CustomColumns"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml"
      xmlns:local="clr-namespace:DataGridSamples"
      xmlns:helpers="clr-namespace:Helpers"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <!-- Control instance -->
        <c1:C1DataGrid x:Name="grid" 
            AutoGeneratingColumn="grid_AutoGeneratingColumn" 
            LoadedRowPresenter="grid_LoadedRowPresenter"
            CanUserAddRows="False" 
            CanUserResizeRows="True"
            RowHeight="35"
            KeyDown="grid_KeyDown"
            Grid.Row="1">
            <c1:C1DataGrid.Columns>
                <c1:DataGridTemplateColumn Header="Template Columns">
                    <c1:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=Description}"
                                       TextAlignment="Left" />
                        </DataTemplate>
                    </c1:DataGridTemplateColumn.CellTemplate>
                    <c1:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding Path=Description, Mode=TwoWay}"
                                     TextAlignment="Center"
                                     MaxLength="50" />
                        </DataTemplate>
                    </c1:DataGridTemplateColumn.CellEditingTemplate>
                </c1:DataGridTemplateColumn>
                <!-- 
                Custom Checkbox column 
                Adds a checkbox to the header and listen to its events
                -->
                <c1:DataGridCheckBoxColumn Binding="{Binding Available, Mode=TwoWay}" SortMemberPath="Available" FilterMemberPath="Available" MinWidth="108" >
                    <c1:DataGridCheckBoxColumn.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:DataGridCheckBoxColumn.Header>
                </c1:DataGridCheckBoxColumn>
            </c1:C1DataGrid.Columns>
        </c1:C1DataGrid>
    </Grid>
</UserControl>
