<UserControl
    x:Class="FlexChartExplorer.PieSelection"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:FlexChartExplorer"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Chart="http://schemas.componentone.com/winfx/2006/xaml"
    DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}"
    mc:Ignorable="d">

    <Grid>
        <Grid.Resources>
            <local:EnumConverter x:Key="enumConverter" />
            <DataTemplate x:Key="cbItemPositionTemplate">
                <TextBlock>
                    <TextBlock.Inlines>
                        <Run Text="Selected item position: " />
                        <Run Text="{Binding .}"/>
                    </TextBlock.Inlines>
                </TextBlock>
            </DataTemplate>
            <DataTemplate x:Key="cbItemOffsetTemplate">
                <TextBlock>
                    <TextBlock.Inlines>
                        <Run Text="Selected item offset:"/>
                        <Run Text="{Binding .}"/>
                    </TextBlock.Inlines>
                </TextBlock>
            </DataTemplate>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" x:Name="panel">
            <ComboBox x:Name="cbItemPosition"
                      ItemsSource="{Binding DataContext.Positions}"
                      ItemTemplate="{StaticResource cbItemPositionTemplate}"
                      Margin="10 5 5 5"
                      Width="250"
                      SelectedValue="{Binding ElementName=pieChart, Path=SelectedItemPosition, Mode=TwoWay, Converter={StaticResource enumConverter}}">
            </ComboBox>
            <ComboBox x:Name="cbItemOffset"
                      Width="210"
                      Margin="5"
                      ItemsSource="{Binding DataContext.Offsets}"
                      ItemTemplate="{StaticResource cbItemOffsetTemplate}"
                      SelectedValue="{Binding ElementName=pieChart, Path=SelectedItemOffset, Mode=TwoWay}">
            </ComboBox>
        </StackPanel>
        <Chart:C1FlexPie x:Name="pieChart" Binding="April" Grid.Row="1" BindingName="Fruit" ItemsSource="{Binding DataContext.Data}" SelectionMode="Point">
            <Chart:C1FlexPie.DataLabel>
                <Chart:PieDataLabel Content="{}{y}"/>
            </Chart:C1FlexPie.DataLabel>
            <Chart:C1FlexPie.SelectionStyle>
                <Chart:ChartStyle Stroke="Red"/>
            </Chart:C1FlexPie.SelectionStyle>
        </Chart:C1FlexPie>
    </Grid>
</UserControl>
