<Page
    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="using:C1.Xaml.Chart"
    xmlns:local="using:FlexChartExplorer"
    DataContext="{Binding RelativeSource={RelativeSource  Mode=Self}}"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.Resources>
            <local:ChartTypeConverter ChartTypes="{Binding DataContext.ChartTypes}" x:Key="chartTypeConverter" />
            <Style TargetType="ComboBox">
                <Style.Setters>
                    <Setter Property="Width" Value="250" />
                    <Setter Property="Margin" Value="10" />
                    <Setter Property="ItemTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <TextBlock>
                                    <TextBlock.Inlines>
                                        <Run Text="{Binding Charttype_Text, Source={StaticResource FlexChartExplorerLocalization}}"></Run>
                                        <Run Text="{Binding Value}"></Run>
                                    </TextBlock.Inlines>
                                </TextBlock>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style.Setters>
            </Style>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <ComboBox x:Name="cbChartType" VerticalAlignment="Center"
                      ItemsSource="{Binding DataContext.ChartTypes}"
                      SelectedIndex="{Binding ElementName=financialSeries, Path=ChartType, Mode=TwoWay, Converter={StaticResource chartTypeConverter}}">
        </ComboBox>
        <Chart:C1FlexChart x:Name="flexChart" ItemsSource="{Binding DataContext.Data}" Grid.Row="1">
            <Chart:C1FlexChart.Series>
                <Chart:Series Binding="Volume" BindingX="Time" ChartType="Column" SeriesName="Volume">
                    <Chart:Series.AxisY>
                        <Chart:Axis Position="Right" MajorGrid="False"></Chart:Axis>
                    </Chart:Series.AxisY>
                </Chart:Series>
                <Chart:Series Binding="High,Low,Open,Close" x:Name="financialSeries" ChartType="Candlestick" BindingX="Time" SeriesName="price" />
            </Chart:C1FlexChart.Series>
            <Chart:C1FlexChart.AxisY>
                <Chart:Axis Min="500" Position="Left" AxisLine="False" MajorGrid="True" MajorTickMarks="None"></Chart:Axis>
            </Chart:C1FlexChart.AxisY>
        </Chart:C1FlexChart>
    </Grid>
</Page>
