<UserControl
    x:Class="FlexChartExplorer.Financial"
    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:Chart="http://schemas.componentone.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:FlexChartExplorer"
    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>
            <Style TargetType="ComboBox">
                <Style.Setters>
                    <Setter Property="Width" Value="250" />
                    <Setter Property="Margin" Value="10" />
                    <Setter Property="HorizontalAlignment" Value="Left" />
                </Style.Setters>
            </Style>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <ComboBox x:Name="cbChartType" VerticalAlignment="Center"
                      ItemsSource="{Binding DataContext.ChartTypes}" ItemTemplate="{StaticResource cbChartTypeTemplate}"
                      SelectedValue="{Binding ElementName=financialSeries, Path=ChartType, Mode=TwoWay, Converter={StaticResource enumConverter}}">
        </ComboBox>
        <Chart:C1FlexChart x:Name="flexChart" ItemsSource="{Binding DataContext.Data}" Grid.Row="1">
            <Chart:Series Binding="Volume" BindingX="Time" ChartType="Column" SeriesName="Volume">
                <Chart:Series.AxisY>
                    <Chart:Axis Position="Right" MajorGrid="False"/>
                </Chart:Series.AxisY>
            </Chart:Series>
            <Chart:Series Binding="High,Low,Open,Close" x:Name="financialSeries" ChartType="Candlestick" BindingX="Time" SeriesName="price" />
            <Chart:C1FlexChart.AxisY>
                <Chart:Axis Min="500" Position="Left" AxisLine="False" MajorGrid="True" MajorTickMarks="None"/>
            </Chart:C1FlexChart.AxisY>
        </Chart:C1FlexChart>
    </Grid>
</UserControl>
