<Page x:Class="FinancialChartExplorer.EventAnnotations"
      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="using:FinancialChartExplorer"
      xmlns:Finance="using:C1.Xaml.Chart.Finance"
      xmlns:Chart="using:C1.Xaml.Chart"
      xmlns:Annotations="using:C1.Xaml.Chart.Annotation"
      xmlns:Interaction="using:C1.Xaml.Chart.Interaction"
      DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}"
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="150"/>
        </Grid.RowDefinitions>
        <Finance:C1FinancialChart x:Name="financialChart" ItemsSource="{Binding Data}"
                                  ToolTipContent="{}Date: {Date}&#x000A;Open: {Open}&#x000A;High: {High}&#x000A;Low: {Low}&#x000A;Close: {Close}&#x000A;Volume: {Volume}"
                                  ChartType="Candlestick"
                                  BindingX="Date">
            <Finance:C1FinancialChart.ToolTip>
                <ToolTip>
                    <ToolTip.ContentTemplate>
                        <DataTemplate>
                            <TextBlock local:TextBoxExt.FormattedText="{Binding}" TextWrapping="Wrap" MaxWidth="250"/>
                        </DataTemplate>
                    </ToolTip.ContentTemplate>
                </ToolTip>
            </Finance:C1FinancialChart.ToolTip>
            <Finance:FinancialSeries x:Name="series" Binding="High,Low,Open,Close,Volume" SeriesName="BOX" ChartType="Line"/>
            <Finance:C1FinancialChart.AxisX>
                <Chart:Axis LabelAngle="45"/>
            </Finance:C1FinancialChart.AxisX>
            <Finance:C1FinancialChart.Layers>
                <Annotations:AnnotationLayer x:Name="annotationLayer">
                </Annotations:AnnotationLayer>
            </Finance:C1FinancialChart.Layers>
        </Finance:C1FinancialChart>
        <Finance:C1FinancialChart x:Name="selectorChart" ItemsSource="{Binding Data}" ChartType="Candlestick" BindingX="Date" ToolTip="{x:Null}" Rendered="selectorChart_Rendered"  Grid.Row="1">
            <Finance:FinancialSeries x:Name="selectorSeries" Binding="High,Low,Open,Close" SymbolSize="6"/>
            <Finance:C1FinancialChart.AxisX>
                <Chart:Axis LabelAngle="45" MajorUnit="3"/>
            </Finance:C1FinancialChart.AxisX>
            <Finance:C1FinancialChart.Layers>
                <Interaction:C1RangeSelector x:Name="selector" ValueChanged="rangeChanged"/>
            </Finance:C1FinancialChart.Layers>
        </Finance:C1FinancialChart>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState x:Name="NarrowLayout">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="0"/>
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="financialChart.FontSize" Value="10"/>
                        <Setter Target="selectorChart.FontSize" Value="10"/>
                        <Setter Target="series.SymbolSize" Value="5"/>
                        <Setter Target="selectorSeries.SymbolSize" Value="5"/>
                        <Setter Target="financialChart.LegendPosition" Value="None"/>
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="WideLayout">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="420" />
                    </VisualState.StateTriggers>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</Page>
