<Page
    x:Class="FlexChartExplorer.AxisGrouping"
    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" />
            <Style TargetType="ComboBox">
                <Setter Property="ItemTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <TextBlock>
                                <TextBlock.Inlines>
                                    <Run Text="Axis X Group Separator: "/>
                                    <Run Text="{Binding Value}" />
                                </TextBlock.Inlines>
                            </TextBlock>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </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="300" Margin="10 0 20 0">
            </ComboBox>
        </StackPanel>
        <Chart:C1FlexChart x:Name="flexChart" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" ChartType="Column" BindingX="Country" 
                        ItemsSource="{Binding Data}" ToolTipContent="{}{x}&#x0a;{seriesName}&#x0a;{y:n0}" Header="World GDP Ranking" Grid.Row="1" >
            <Chart:C1FlexChart.HeaderStyle>
                <Chart:ChartStyle FontSize="20" FontFamily="GenericSansSerif"/>
            </Chart:C1FlexChart.HeaderStyle>
            <Chart:Series SeriesName="GDP, current prices" Binding="CurrentPrices"/>
            <Chart:Series SeriesName="GDP based on PPP valuation" Binding="PPPValuation"/>
            <Chart:C1FlexChart.AxisX>
                <Chart:Axis GroupSeparator="Vertical" GroupNames="Continent" />
            </Chart:C1FlexChart.AxisX>
            <Chart:C1FlexChart.AxisY>
                <Chart:Axis Title="GDP (billion USD)" MajorGrid="True"/>
            </Chart:C1FlexChart.AxisY>
        </Chart:C1FlexChart>
    </Grid>
</Page>
