<Page
    x:Class="FlexChartExplorer.DateTimeAxisGrouping"
    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>
        <Grid.Resources>
            <local:EnumConverter x:Key="enumConverter" />
            <local:GroupSeparatorConverter GroupSeparator="{Binding DataContext.GroupSeparator}" x:Key="groupSeparatorConverter" />
            <local:IntToGroupVisibilityLevelConverter x:Key="groupVisibilityConverter" />
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Margin="10">
            <ComboBox ItemsSource="{Binding DataContext.GroupSeparator}"
                      SelectedIndex="{Binding ElementName=flexChart, Path=AxisX.GroupSeparator, Mode=TwoWay, Converter={StaticResource groupSeparatorConverter}}" 
                      Width="280" Margin="10 0 20 0">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock>
                            <TextBlock.Inlines>
                                <Run Text="Axis X Group Separator: " />
                                <Run Text="{Binding Value}" />
                            </TextBlock.Inlines>
                        </TextBlock>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            <ComboBox ItemsSource="{Binding DataContext.ExpansionOptions}" SelectedValue="{Binding ElementName=flexChart, Path=AxisX.GroupVisibilityLevel, Mode=TwoWay, Converter={StaticResource groupVisibilityConverter}}"
                      SelectedItem="Expanded = 1" Width="280" Margin="10 0 20 0" />
            <ComboBox ItemsSource="{Binding DataContext.MajorUnitOptions}" SelectedItem="Default"
                      Width="180" Margin="10 0 20 0" SelectionChanged="cbMajorUnit_SelectionChanged">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock>
                            <TextBlock.Inlines>
                                <Run Text="MajorUnit: " />
                                <Run Text="{Binding}" />
                            </TextBlock.Inlines>
                        </TextBlock>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            <CheckBox x:Name="cbLabelMin" Content="Label Min" VerticalAlignment="Center"
                      IsChecked="{Binding ElementName=flexChart, Path=AxisX.LabelMin, Mode=TwoWay}" Margin="10 0 20 0">
            </CheckBox>
            <CheckBox x:Name="cbLabelMax" Content="Label Max" VerticalAlignment="Center"
                      IsChecked="{Binding ElementName=flexChart, Path=AxisX.LabelMax, Mode=TwoWay}" Margin="10 0 20 0">
            </CheckBox>
        </StackPanel>
        <Chart:C1FlexChart x:Name="flexChart" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" ChartType="Line" BindingX="Time" 
                        ItemsSource="{Binding Data}" Grid.Row="1" >
            <Chart:Series Binding="Price"/>
            <Chart:C1FlexChart.AxisX>
                <Chart:Axis GroupSeparator="Horizontal" Format="d MMM" LabelAngle="90" GroupVisibilityLevel="1"/>
            </Chart:C1FlexChart.AxisX>
        </Chart:C1FlexChart>
    </Grid>
</Page>
