<UserControl
    x:Class="TreeViewSamples.HierarchicalTemplate"
    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="using:C1.Xaml"
    xmlns:src="using:TreeViewSamples"
    mc:Ignorable="d"
    d:DataContext="{d:DesignData Source=/Data/SampleTeams.xaml}">

    <UserControl.Resources>

        <!-- The Template and Style selectors will look for the data templates and styles
              in their local resource collection -->
        <src:CustomTemplateSelector x:Key="WorldCupTemplateSelector">
            <src:CustomTemplateSelector.Resources>
                <ResourceDictionary>
                    <c1:C1HierarchicalDataTemplate x:Key="GroupTemplate" ItemsSource="{Binding Teams}">
                        <DataTemplate>
                            <Border VerticalAlignment="Top" Height="45" Width="272" Margin="0 2 0 2" Background="#FF6DA00F">
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="../../Resources/country/Ball.png" Width="18" Height="17" Margin="10,0,0,0" Stretch="Fill" />
                                    <TextBlock Text="{Binding GroupName}" Foreground="White" TextWrapping="Wrap" VerticalAlignment="Center" Margin="10,0,0,0" FontSize="24" />
                                </StackPanel>
                            </Border>
                        </DataTemplate>
                    </c1:C1HierarchicalDataTemplate>
                    <c1:C1HierarchicalDataTemplate x:Key="TeamTemplate">
                        <DataTemplate>
                            <Border VerticalAlignment="Top" Height="70" Width="250" Background="#FFACD52F" Margin="0 2 0 2">
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                    <Image Source="{Binding FlagUri}" Width="16" Height="16" Margin="10,2,0,0" Stretch="Fill" VerticalAlignment="Top" />
                                    <StackPanel Margin="0,0,10,0">
                                        <TextBlock Foreground="Black" Text="{Binding CountryName}" TextWrapping="Wrap" VerticalAlignment="Center" Margin="10,0,0,0" FontSize="18" />
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Foreground="Black" Text="World Cups Won:" TextWrapping="Wrap" VerticalAlignment="Center" Margin="10,0,0,0" FontSize="14" />
                                            <TextBlock Foreground="Black" Text="{Binding WorldCupWon}" TextWrapping="Wrap" VerticalAlignment="Center" Margin="2,0,0,0" FontSize="14" />
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Foreground="Black" Text="TopScorer:" TextWrapping="Wrap" VerticalAlignment="Center" Margin="10,0,0,0" FontSize="14" />
                                            <TextBlock Foreground="Black" Text="{Binding TopScorer}" TextWrapping="Wrap" VerticalAlignment="Center" Margin="2,0,0,0" FontSize="14" />
                                        </StackPanel>
                                    </StackPanel>
                                </StackPanel>
                            </Border>
                        </DataTemplate>
                    </c1:C1HierarchicalDataTemplate>
                </ResourceDictionary>
            </src:CustomTemplateSelector.Resources>
        </src:CustomTemplateSelector>
        <src:CustomStyleSelector x:Key="WorldCupStyleSelector">
            <src:CustomStyleSelector.Resources>
                <ResourceDictionary>
                    <Style x:Key="ExpandedStyle" TargetType="c1:C1TreeViewItem">
                        <Setter Property="IsExpanded" Value="True" />
                    </Style>
                </ResourceDictionary>
            </src:CustomStyleSelector.Resources>
        </src:CustomStyleSelector>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <c1:C1TreeView x:Name="ReflectionTreeView" ItemTemplateSelector="{StaticResource WorldCupTemplateSelector}" ItemContainerStyleSelector="{StaticResource WorldCupStyleSelector}" ItemsSource="{Binding}">
        </c1:C1TreeView>
    </Grid>
</UserControl>
