<UserControl
    x:Class="FlexChartExplorer.Selection"
    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:local="clr-namespace:FlexChartExplorer"
    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" />
            <DataTemplate x:Key="cbChartTypeTemplate">
                <TextBlock>
                    <TextBlock.Inlines>
                        <Run Text="Chart type: "/>
                        <Run Text="{Binding .}"/>
                    </TextBlock.Inlines>
                </TextBlock>
            </DataTemplate>
            <DataTemplate x:Key="cbStackedTemplate">
                <TextBlock>
                    <TextBlock.Inlines>
                        <Run Text="Stacking: "/>
                        <Run Text="{Binding .}"/>
                    </TextBlock.Inlines>
                </TextBlock>
            </DataTemplate>
            <Style TargetType="ComboBox">
                <Setter Property="VerticalAlignment" Value="Center" />
            </Style>
            <DataTemplate x:Key="cbSelectionModeTemplate">
                <TextBlock>
                    <TextBlock.Inlines>
                        <Run Text="Mode: " />
                        <Run Text="{Binding .}"/>
                    </TextBlock.Inlines>
                </TextBlock>
            </DataTemplate>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Margin="10 0">
            <ComboBox Width="210" x:Name="cbChartType" 
                      ItemsSource="{Binding DataContext.ChartTypes}"
                      ItemTemplate="{StaticResource cbChartTypeTemplate}"
                      SelectedValue="{Binding ElementName=flexChart, Path=ChartType, Mode=TwoWay, Converter={StaticResource enumConverter}}">
            </ComboBox>
            <ComboBox Width="200" Margin="10" x:Name="cbStacked" 
                      ItemsSource="{Binding DataContext.Stackings}" 
                      ItemTemplate="{StaticResource cbStackedTemplate}"
                      SelectedValue="{Binding ElementName=flexChart, Path=Stacking, Mode=TwoWay, Converter={StaticResource enumConverter}}">
            </ComboBox>
            <ComboBox Width="200" Margin="10" x:Name="cbSelectionMode" 
                      ItemsSource="{Binding DataContext.SelectionModes}" 
                      ItemTemplate="{StaticResource cbSelectionModeTemplate}"
                      SelectedValue="{Binding ElementName=flexChart, Path=SelectionMode, Mode=TwoWay, Converter={StaticResource enumConverter}}">
            </ComboBox>
        </StackPanel>
        <Chart:C1FlexChart x:Name="flexChart" ItemsSource="{Binding DataContext.Data}" BindingX="Fruit" SelectionMode="Series" Grid.Row="1">
            <Chart:Series SeriesName="March" Binding="March"/>
            <Chart:Series SeriesName="April" Binding="April"/>
            <Chart:Series SeriesName="May" Binding="May"/>
            <Chart:C1FlexChart.SelectionStyle>
                <Chart:ChartStyle Stroke="Red"/>
            </Chart:C1FlexChart.SelectionStyle>
        </Chart:C1FlexChart>
    </Grid>
</UserControl>
