<Page
    x:Class="FlexChartExplorer.AutoLabels"
    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">
    <Page.Resources>
        <local:EnumConverter x:Key="enumConverter" />
        <local:ChartTypeConverter ChartTypes="{Binding DataContext.ChartTypes}" x:Key="chartTypeConverter" />
        <Style TargetType="ComboBox">
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
        <DataTemplate x:Key="cbDataShapeTemplate">
            <TextBlock>
                <TextBlock.Inlines>
                    <Run Text="{Binding DataShape_Text, Source={StaticResource FlexChartExplorerLocalization}}"></Run>
                    <Run Text="{Binding}"></Run>
                </TextBlock.Inlines>
            </TextBlock>
        </DataTemplate>
        <DataTemplate x:Key="cbOverlappingTemplate">
            <TextBlock>
                <TextBlock.Inlines>
                    <Run Text="{Binding OverlappedLabels_Text, Source={StaticResource FlexChartExplorerLocalization}}"></Run>
                    <Run Text="{Binding}"></Run>
                </TextBlock.Inlines>
            </TextBlock>
        </DataTemplate>
    </Page.Resources>

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">
            <ComboBox Width="160" x:Name="cbDataShape" 
                      ItemsSource="{Binding DataContext.DataShapes}" 
                      ItemTemplate="{StaticResource cbDataShapeTemplate}"
                      SelectedValue="{Binding DataContext.DataShape, Mode=TwoWay, Converter={StaticResource enumConverter},ConverterParameter=DataShape}">
            </ComboBox>
            <ComboBox Width="210" Margin="10" x:Name="cbOverlapping" 
                      ItemsSource="{Binding DataContext.Overlappings}" 
                      ItemTemplate="{StaticResource cbOverlappingTemplate}"
                      SelectedValue="{Binding ElementName=flexChart, Path=DataLabel.Overlapping, Mode=TwoWay, Converter={StaticResource enumConverter},ConverterParameter=LabelOverlapping}">
            </ComboBox>
            <CheckBox x:Name="cbLabelBorder" Content="{Binding LabelBorder_Content, Source={StaticResource FlexChartExplorerLocalization}}"
                      IsChecked="{Binding ElementName=flexChart, Path=DataLabel.Border, Mode=TwoWay}">
            </CheckBox>
        </StackPanel>

        <Chart:C1FlexChart x:Name="flexChart" ChartType="Scatter" ItemsSource="{Binding DataContext.Data}" Grid.Row="1" LegendPosition="None">
            <Chart:C1FlexChart.DataLabel>
                <Chart:DataLabel Content="{}{pointIndex}" Position="Auto" ConnectingLine="True"/>
            </Chart:C1FlexChart.DataLabel>
            <Chart:Series SeriesName="Points" BindingX="X" Binding="Y"/>
        </Chart:C1FlexChart>
    </Grid>
</Page>
