<UserControl
    x:Class="FlexChartExplorer.Binding"
    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" />
            <DataTemplate x:Key="cbChartTypeTemplate">
                <TextBlock>
                    <TextBlock.Inlines>
                        <Run Text="Chart type: "/>
                        <Run Text="{Binding .}"/>
                    </TextBlock.Inlines>
                </TextBlock>
            </DataTemplate>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Margin="10">
            <ComboBox x:Name="cbChartType" VerticalAlignment="Center" Width="210"
                      ItemsSource="{Binding DataContext.ChartTypes}" ItemTemplate="{StaticResource cbChartTypeTemplate}"
                      SelectedValue="{Binding ElementName=flexChart, Path=ChartType, Mode=TwoWay, Converter={StaticResource enumConverter}}">
            </ComboBox>
            <CheckBox x:Name="cbInterpolateNulls" Content="InterpolateNulls" Margin="10 0" VerticalAlignment="Center"
                      IsChecked="{Binding ElementName=flexChart, Path=Options.InterpolateNulls, Mode=TwoWay}">
            </CheckBox>
            <CheckBox x:Name="cbLegendToggle" Content="LegendToggle" VerticalAlignment="Center"
                      IsChecked="{Binding ElementName=flexChart, Path=LegendToggle, Mode=TwoWay}">
            </CheckBox>
        </StackPanel>
        <Chart:C1FlexChart x:Name="flexChart" BindingX="Date" Grid.Row="1" ChartType="Line" ItemsSource="{Binding DataContext.Data}">
            <Chart:Series SeriesName="Downloads" Binding="Downloads"/>
            <Chart:Series SeriesName="Sales" Binding="Sales"/>
        </Chart:C1FlexChart>
    </Grid>
</UserControl>
