<Page
    x:Class="FlexChartExplorer.Binding"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:FlexChartExplorer"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Chart="using:C1.Xaml.Chart"
    DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}"
    mc:Ignorable="d">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.Resources>
            <Style TargetType="ComboBox">
                <Setter Property="VerticalAlignment" Value="Center" />
            </Style>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">
            <CheckBox x:Name="cbInterpolateNulls" Content="{Binding InterpolateNulls_Content, Source={StaticResource FlexChartExplorerLocalization}}" Margin="10 0"
                      IsChecked="{Binding ElementName=flexChart, Path=Options.InterpolateNulls, Mode=TwoWay}">
            </CheckBox>
            <CheckBox x:Name="cbLegendToggle" Content="{Binding LegendToggle_Content, Source={StaticResource FlexChartExplorerLocalization}}"
                      IsChecked="{Binding ElementName=flexChart, Path=LegendToggle, Mode=TwoWay}">
            </CheckBox>
        </StackPanel>
        <Chart:C1FlexChart x:Name="flexChart" ChartType="Line" BindingX="Date" ItemsSource="{Binding DataContext.Data}" LegendPosition="Bottom" Grid.Row="1">
            <Chart:C1FlexChart.Series>
                <Chart:Series SeriesName="Downloads" Binding="Downloads"></Chart:Series>
                <Chart:Series SeriesName="Sales" Binding="Sales"></Chart:Series>
            </Chart:C1FlexChart.Series>
        </Chart:C1FlexChart>
    </Grid>
    <Page.BottomAppBar>
        <AppBar>
            <AppBar.Resources>
                <Style TargetType="ComboBox">
                    <Style.Setters>
                        <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>
                <local:ChartTypeConverter ChartTypes="{Binding DataContext.ChartTypes}" x:Key="chartTypeConverter" />
            </AppBar.Resources>
            <ComboBox x:Name="cbChartType" ItemsSource="{Binding DataContext.ChartTypes}" VerticalAlignment="Center" Width="210"
                      SelectedIndex="{Binding DataContext.FlexChartInstance.ChartType, Mode=TwoWay, Converter={StaticResource chartTypeConverter}}">
            </ComboBox>
        </AppBar>
    </Page.BottomAppBar>
</Page>
