<UserControl
    x:Class="FlexChartExplorer.TreeMapNodeColor"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:FlexChartExplorer"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Chart="http://schemas.componentone.com/winfx/2006/xaml"
    DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}"
    mc:Ignorable="d">

    <Grid>
        <Grid.Resources>
            <local:EnumConverter x:Key="enumConverter" />
            <Style TargetType="ComboBox" x:Key="leftPcComboBoxStyle">
                <Setter Property="Width" Value="160" />
                <Setter Property="Margin" Value="10 5 5 5" />
            </Style>
            <Style TargetType="ComboBox" x:Key="rightPcComboBoxStyle">
                <Setter Property="Width" Value="190" />
                <Setter Property="Margin" Value="5" />
            </Style>
            <local:BooleanConverter x:Key="booleanConverter" />
            <local:VisibilityConverter x:Key="visibilityConverter" />
            <Style TargetType="ComboBox">
                <Setter Property="Margin" Value="10" />
            </Style>
            <DataTemplate x:Key="cbMaxDepthTemplate">
                <TextBlock>
                    <TextBlock.Inlines>
                        <Run Text="Max Depth: "/>
                        <Run Text="{Binding .}"/>
                    </TextBlock.Inlines>
                </TextBlock>
            </DataTemplate>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel x:Name="stackPanel" Orientation="Horizontal">
            <StackPanel Orientation="Horizontal">
                <ComboBox x:Name="cbMaxDepth"
                      SelectedValue="{Binding ElementName=treeMap, Path=MaxDepth, Mode=TwoWay}" 
                      ItemsSource="{Binding DataContext.MaxDepths}" Style="{StaticResource leftPcComboBoxStyle}"
                      ItemTemplate="{StaticResource cbMaxDepthTemplate}">
                </ComboBox>
            </StackPanel>
        </StackPanel>
        <Chart:C1TreeMap x:Name="treeMap" Grid.Row="1" MaxDepth="2" Binding="CurrentSales" BindingName="Type" ChildItemsPath="Items"
                         ItemsSource="{Binding DataContext.Data}" LegendPosition="None" NodeRendering="treeMap_NodeRendering" ToolTipContent="Current Sales:{CurrentSales:C0}&#x000A;Previous Sales:{PreviousSales:C0}">
            <Chart:C1TreeMap.DataLabel>
                <Chart:DataLabel Content="{}{Type}" Position="Center"/>
            </Chart:C1TreeMap.DataLabel>
        </Chart:C1TreeMap>
    </Grid>
</UserControl>
