<UserControl x:Class="HierarchicalDataTemplateWPF.HierarchicalDataTemplateSample"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:HierarchicalDataTemplateWPF"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>

        <!-- template for Team objects -->
        <DataTemplate x:Key="TeamTemplate" >
            <Border Background="#ff88bde6" Padding="4" >
                <TextBlock FontStyle="Italic" Text="{Binding Path=Name}" />
            </Border>
        </DataTemplate>

        <!-- template for Division objects -->
        <HierarchicalDataTemplate x:Key="DivisionTemplate" 
            ItemsSource="{Binding Path=Teams}" 
            ItemTemplate="{StaticResource TeamTemplate}">
            <Border Background="#fffbb258" Padding="20" >
                <TextBlock Text="{Binding Path=Name}" FontWeight="Bold" />
            </Border>
        </HierarchicalDataTemplate>

        <!-- template for League objects -->
        <HierarchicalDataTemplate x:Key="LeagueTemplate" 
            ItemsSource="{Binding Path=Divisions}" 
            ItemTemplate="{StaticResource DivisionTemplate}">
            <Border Background="#ff90cd97" Padding="40" >
                <TextBlock Text="{Binding Path=Name}" FontWeight="Bold" />
            </Border>
        </HierarchicalDataTemplate>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>

        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Padding="0">
            <c1:C1OrgChart 
                Name="_chart" ItemTemplate="{StaticResource LeagueTemplate}" 
                ConnectorDashArray="1 2" ConnectorStroke="Gray" 
                HorizontalAlignment="Center" VerticalAlignment="Center" />
        </ScrollViewer>

        <TreeView Name="_tree" Grid.Row="1" ItemTemplate="{StaticResource LeagueTemplate}" />
    </Grid>
</UserControl>
