<UserControl x:Class="DrillDown.TreemapDemo"
             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:local="clr-namespace:DrillDown"
             xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid Margin="10">
        <Grid.Resources>
            <local:IntToVisibilityConverter x:Key="ITVConverter"/>
            <local:ShowNavigateConverter x:Key="SNConverter"/>
            <Style TargetType="StackPanel">
                <Setter Property="Orientation" Value="Horizontal"/>
                <Setter Property="Margin" Value="0 5"/>
            </Style>
            <Style TargetType="ComboBox">
                <Setter Property="Margin" Value="10 0"/>
            </Style>
        </Grid.Resources>

        <Grid Margin="10">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <StackPanel>
                <StackPanel.Resources>
                    <Style TargetType="TextBlock">
                        <Setter Property="VerticalAlignment" Value="Center"/>
                        <Setter Property="FontSize" Value="15"/>
                    </Style>
                </StackPanel.Resources>
                <StackPanel Visibility="{Binding TreemapDataLayer.Depth, Converter={StaticResource SNConverter}, ConverterParameter=1}">
                    <c1:C1HyperlinkButton
                                    Content="{Binding TreemapDataLayer.Histories[0].Key}"
                                    Command="{Binding TreemapDataLayer.BackCommand}"
                                    CommandParameter="0"
                                    FontSize="15"/>
                    <TextBlock Text=" \ "/>
                </StackPanel>
                <StackPanel Visibility="{Binding TreemapDataLayer.Depth, Converter={StaticResource SNConverter}, ConverterParameter=2}">
                    <c1:C1HyperlinkButton
                                    Content="{Binding TreemapDataLayer.Histories[1].Key}"
                                    Command="{Binding TreemapDataLayer.BackCommand}"
                                    CommandParameter="1"
                                    FontSize="15"/>
                    <TextBlock Text=" \ "/>
                </StackPanel>
                <StackPanel Visibility="{Binding TreemapDataLayer.Depth, Converter={StaticResource SNConverter}, ConverterParameter=3}">
                    <c1:C1HyperlinkButton
                                    Content="{Binding TreemapDataLayer.Histories[2].Key}"
                                    Command="{Binding TreemapDataLayer.BackCommand}"
                                    CommandParameter="2"
                                    FontSize="15"/>
                    <TextBlock Text=" \ "/>
                </StackPanel>
                <StackPanel Visibility="{Binding TreemapDataLayer.Depth, Converter={StaticResource SNConverter}, ConverterParameter=0}">
                    <TextBlock Text="{Binding TreemapDataLayer.CurrentType}"/>
                </StackPanel>
            </StackPanel>
            <c1:C1TreeMap
                        x:Name="treemap"
                        Grid.Row="1"
                        DataContext="{Binding TreemapDataLayer}"
                        ItemsSource="{Binding ItemsSource}"
                        Binding="Sales"
                        BindingName="Type"
                        MaxDepth="1"
                        ChildItemsPath="Items" 
                        MouseLeftButtonDown="HandleDrillDown">
                <c1:C1TreeMap.DataLabel>
                    <c1:DataLabel Content="{}{Type}" Position="Center"/>
                </c1:C1TreeMap.DataLabel>
            </c1:C1TreeMap>
        </Grid>
    </Grid>
</UserControl>
