<UserControl x:Class="DataGridSamples.DataGridTreeViewFilter"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:DataGridSamples"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <local:CustomTemplateSelector x:Key="TreeViewFilterTemplateSelector">
            <local:CustomTemplateSelector.Resources>
                <ResourceDictionary>
                    <HierarchicalDataTemplate x:Key="GroupTemplate" ItemsSource="{Binding Children}">
                        <CheckBox Content="{Binding Key}" IsThreeState="True" IsChecked="{Binding IsChecked, Mode=TwoWay}"/>
                    </HierarchicalDataTemplate>
                    <HierarchicalDataTemplate x:Key="ProductTemplate">
                        <CheckBox Content="{Binding Product.ProductNumber}" IsThreeState="False" IsChecked="{Binding IsChecked, Mode=TwoWay}"/>
                    </HierarchicalDataTemplate>
                </ResourceDictionary>
            </local:CustomTemplateSelector.Resources>
        </local:CustomTemplateSelector>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Margin="8">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <CheckBox x:Name="chkSelectAll" Content="Select All" Margin="0 0 0 4"/>
        <c1:C1TreeView x:Name="treeItems" ItemTemplateSelector="{StaticResource TreeViewFilterTemplateSelector}" Grid.Row="1"/>
    </Grid>
</UserControl>
