<UserControl x:Class="LineMarkerSample.LineMarkerDemo"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:LineMarkerSample"
             xmlns:Chart="http://schemas.componentone.com/winfx/2006/xaml"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <local:LineMarkerViewModel x:Key="ViewModel" />
    </UserControl.Resources>
    <Grid DataContext="{StaticResource ViewModel}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock Text="{Binding Description}" TextWrapping="Wrap" Margin="10"/>
        <StackPanel Grid.Row="1">
            <StackPanel.Resources>
                <Style TargetType="ComboBox">
                    <Setter Property="Width" Value="200" />
                    <Setter Property="Margin" Value="10 10 10 0" />
                </Style>
                <DataTemplate x:Key="cbLineTypeTemplate">
                    <TextBlock>
                        <TextBlock.Inlines>
                            <Run Text="Line Type: "/>
                            <Run Text="{Binding .}" />
                        </TextBlock.Inlines>
                    </TextBlock>
                </DataTemplate>
                <DataTemplate x:Key="cbLineMarkerAlignmentTemplate">
                    <TextBlock>
                        <TextBlock.Inlines>
                            <Run Text="Line Marker Alignment: "/>
                            <Run Text="{Binding Key, Mode=OneWay}" />
                        </TextBlock.Inlines>
                    </TextBlock>
                </DataTemplate>
                <DataTemplate x:Key="cbLineMarkerInteractionTemplate">
                    <TextBlock>
                        <TextBlock.Inlines>
                            <Run Text="Line Marker Interaction: "/>
                            <Run Text="{Binding .}" />
                        </TextBlock.Inlines>
                    </TextBlock>
                </DataTemplate>
                <DataTemplate x:Key="cbDragContentTemplate">
                    <TextBlock>
                        <TextBlock.Inlines>
                            <Run Text="Drag Content: "/>
                            <Run Text="{Binding .}" />
                        </TextBlock.Inlines>
                    </TextBlock>
                </DataTemplate>
                <DataTemplate x:Key="cbDragLinesTemplate">
                    <TextBlock>
                        <TextBlock.Inlines>
                            <Run Text="Drag Lines: "/>
                            <Run Text="{Binding .}" />
                        </TextBlock.Inlines>
                    </TextBlock>
                </DataTemplate>
                <local:EnumConverter x:Key="EmConverter" />
                <local:VisibilityConverter x:Key="VConverter" />
            </StackPanel.Resources>
            <StackPanel Orientation="Horizontal">
                <ComboBox x:Name="cbLineType" ItemsSource="{Binding LineType}" ItemTemplate="{StaticResource cbLineTypeTemplate}" SelectedValue="{Binding ElementName=lineMarker, Path=Lines, Mode=TwoWay, Converter={StaticResource EmConverter}}"/>
                <ComboBox x:Name="cbLineMarkerAlignment" Width="250" ItemsSource="{Binding LineMarkerAlignments}" ItemTemplate="{StaticResource cbLineMarkerAlignmentTemplate}" SelectedValue="{Binding ElementName=lineMarker, Path=Alignment, Mode=TwoWay, Converter={StaticResource EmConverter}, ConverterParameter={StaticResource ViewModel}}"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <ComboBox x:Name="cbLineMarkerInteraction" ItemsSource="{Binding LineMarkerInteraction}" ItemTemplate="{StaticResource cbLineMarkerInteractionTemplate}" SelectedValue="{Binding ElementName=lineMarker, Path=Interaction, Mode=TwoWay, Converter={StaticResource EmConverter}}"/>
                <ComboBox x:Name="cbDragContent" Visibility="{Binding ElementName=lineMarker, Path=Interaction, Converter={StaticResource VConverter}}" ItemsSource="{Binding CanDrag}" ItemTemplate="{StaticResource cbDragContentTemplate}" SelectedValue="{Binding ElementName=lineMarker, Path=DragContent, Mode=TwoWay, Converter={StaticResource EmConverter}}"/>
                <ComboBox x:Name="cbDragLines" Visibility="{Binding ElementName=lineMarker, Path=Interaction, Converter={StaticResource VConverter}}" ItemsSource="{Binding CanDrag}" ItemTemplate="{StaticResource cbDragLinesTemplate}" SelectedValue="{Binding ElementName=lineMarker, Path=DragLines, Mode=TwoWay, Converter={StaticResource EmConverter}}"/>
            </StackPanel>
        </StackPanel>
        <Chart:C1FlexChart Background="White" x:Name="flexChart" BindingX="Date" ChartType="Line" ItemsSource="{Binding Items}" ToolTip="{x:Null}" Grid.Row="2">
            <Chart:Series Binding="Input" SeriesName="Intput"/>
            <Chart:Series Binding="Output" SeriesName="Output"/>
            <Chart:C1FlexChart.AxisY>
                <Chart:Axis MajorUnit="2" Position="Left" MajorGrid="True" AxisLine="False" MajorTickMarks="None" />
            </Chart:C1FlexChart.AxisY>
            <Chart:C1FlexChart.Layers>
                <Chart:C1LineMarker x:Name="lineMarker" PositionChanged="OnLineMarkerPositionChanged"/>
            </Chart:C1FlexChart.Layers>
        </Chart:C1FlexChart>
    </Grid>
</UserControl>
