<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:ForzaUI;assembly="
                    xmlns:System="clr-namespace:System;assembly=mscorlib">

    <ControlTemplate x:Key="A_ControlTemplate_Arrow_Left" TargetType="Control">
        <Grid Width="28" Height="28">
            <local:FZMaterial x:Name="ButtonStroke"
                              Style="{StaticResource A_Style_FZMaterial_SpinnerButtonBorder}" />
            <local:FZMaterial x:Name="arrow"
                            ImageSource="/Textures/Data_Bound/Spinner/Spinner_Arrow.png"
                            Focusable="False" 
                            IsHitTestVisible="True"
                            Color="{DynamicResource A_Color_Spinner_ArrowUnselected}"/>
        </Grid>
        <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType=local:SpinnerControl}}"
                         Value="True" >
                <Setter TargetName="arrow"
                        Property="Color"
                        Value="{DynamicResource A_Color_Spinner_ArrowSelected}" />
                <Setter TargetName="arrow"
                        Property="Opacity"
                        Value="1" />
            </DataTrigger>
            <DataTrigger Binding="{Binding IsEnabled, RelativeSource={RelativeSource AncestorType=local:SpinnerControl}}"
                         Value="False" >
                <Setter TargetName="arrow"
                        Property="Color"
                        Value="{DynamicResource A_Color_Spinner_ArrowDisabled}" />
                <Setter TargetName="arrow"
                        Property="Opacity"
                        Value="{StaticResource A_Double_OptionsItemOpacity_Disabled}" />
            </DataTrigger>
            <Trigger Property="IsEnabled" 
                         Value="False">
                <Setter TargetName="arrow" Property="Color" Value="{DynamicResource H_Color_Primary_Grey_70pc}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="A_Style_Arrow_Left" TargetType="Control">
        <Setter Property="Margin" Value="0,0,12,0" />
        <Setter Property="Template" Value="{StaticResource A_ControlTemplate_Arrow_Left}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="RenderTransformOrigin" Value="0.5, 0.5" />

    </Style>

    <Style x:Key="A_Style_Arrow_Right" TargetType="Control">
        <Setter Property="Margin" Value="12,0,0,0" />
        <Setter Property="Template" Value="{StaticResource A_ControlTemplate_Arrow_Left}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="RenderTransformOrigin" Value="0.5, 0.5" />
        <Setter Property="RenderTransform">
            <Setter.Value>
                <RotateTransform Angle="180" />
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="A_Style_Arrow_Up" TargetType="Control">
        <Setter Property="Margin" Value="0,0,0,10" />
        <Setter Property="Template" Value="{StaticResource A_ControlTemplate_Arrow_Left}" />
        <Setter Property="RenderTransformOrigin" Value="0.5, 0.5" />
        <Setter Property="RenderTransform">
            <Setter.Value>
                <RotateTransform Angle="90" />
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="A_Style_Arrow_Down"
           TargetType="Control">
        <Setter Property="Margin" Value="0,10,0,0" />
        <Setter Property="Template" Value="{StaticResource A_ControlTemplate_Arrow_Left}" />
        <Setter Property="RenderTransformOrigin" Value="0.5, 0.5" />
        <Setter Property="RenderTransform">
            <Setter.Value>
                <RotateTransform Angle="270" />
            </Setter.Value>
        </Setter>
    </Style>

    <CornerRadius x:Key="A_Stroke_CornerRadius_Divider">2,2,2,2</CornerRadius>

    <Style x:Key="A_Style_FZMaterial_SpinnerButtonBorder" TargetType="local:FZMaterial">
        <Setter Property="Color" Value="{DynamicResource H_Color_Primary_White}" />
        <Setter Property="Margin" Value="-3"/>
        <Setter Property="Visibility" Value="Collapsed"/>
        <Setter Property="Preset">
            <Setter.Value>
                <FZMaterialPresetRoundtangleStroke  Thickness="4"
                                                    CornerRadius="{Binding ActualWidth, Converter={MathOperationConverter Operation=Divide}, 
                                                                  ConverterParameter={StaticResource A_Stroke_CornerRadius_Divider}, 
                                                                  RelativeSource={RelativeSource AncestorType=FZMaterial}}"/>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource AncestorType=local:Control}}" Value="True" />
                    <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=local:FZButton}}" Value="True"/>
                </MultiDataTrigger.Conditions>
                <Setter Property="Visibility" Value="Visible" />
        </MultiDataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="A_Style_Button_SpinnerArrowButton" TargetType="local:FZButton">
        <Setter Property="Width"
                Value="28" />
        <Setter Property="Height"
                Value="28" />
        <Setter Property="MinWidth"
                Value="1" />
        <Setter Property="MinHeight"
                Value="1" />
        <Setter Property="VerticalAlignment"
                Value="Center" />
        <Setter Property="HorizontalAlignment"
                Value="Center" />
        <Setter Property="ClickMode"
                Value="Press" />
        <Setter Property="IsSfxEnabled"
                Value="False" />
        <Setter Property="Focusable"
                Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:FZButton}">
                    <Grid>
                        <ContentPresenter HorizontalAlignment="Center"
                                          VerticalAlignment="Center"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Thickness x:Key="A_Margin_SpinnerTrailingMargin">0,0,0,0</Thickness>

    <AutoScrollSettings x:Key="H_AutoScrollSettings_SpinnerItemText"
        Speed="30"
        ScrollOrientation="Horizontal"
        InitialPause="0:0:01.0"
        />

    <Style x:Key="H_Style_AutoScroll_PauseWhenNotSelected_SpinnerItemText" BasedOn="{StaticResource H_Style_Text_ListOptionLabelForAutoScroll}" TargetType="FZTextBlock">
        <Setter Property="Margin" Value="5,0,5,0"/>
        <Setter Property="MaxWidth" Value="320"/>
        <Setter Property="ClipToBounds" Value="False"/>
        <Setter Property="Stretch" Value="None" />
        <Setter Property="TextTrimming" Value="None"/>
        <Setter Property="AutoScroll" Value="{StaticResource H_AutoScrollSettings_SpinnerItemText}" />
        <Setter Property="AutoScroll.AllowScrolling" Value="False" />
        <Style.Triggers>
            <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True">
                <Setter Property="AutoScroll.AllowScrolling" Value="True" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <CompareConverter x:Key="H_Converter_SpinnerStateToEnabled" 
        Value="{x:Static SpinnerButtonState.Active}"
        Equal="{StaticResource A_Boolean_True}"
        NotEqual="{StaticResource A_Boolean_False}" />

    <Style x:Key="A_Style_SpinnerControl_Default_Internal" TargetType="local:SpinnerControl">
        <Style.Resources>
            <GridLength x:Key="A_GridLength_SpinnerWidth">375</GridLength>
        </Style.Resources>
        <Setter Property="Focusable" Value="True"/>
        <Setter Property="local:ScreenReader.SelectedNumber"
                Value="{Binding (ItemsControl.AlternationIndex), RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Converter={StaticResource A_IndexToNumberConverter}, FallbackValue=0}" />
        <Setter Property="local:ScreenReader.SelectedCount"
                Value="{Binding Items.Count, RelativeSource={RelativeSource AncestorType={x:Type Selector}}, FallbackValue=0}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:SpinnerControl">
                    <Grid VerticalAlignment="Center"
                          Margin="{DynamicResource A_Thickness_SpinnerMargin_Dynamic}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="{DynamicResource A_GridLength_SpinnerWidth}" />
                        </Grid.ColumnDefinitions>

                        <Grid Grid.Column="0">
                            <local:FZTextBlock x:Name="FZTextBlock_SpinnerLabelText"
                                               Style="{DynamicResource A_Style_FZTextBlock_SpinnerTitle_Dynamic}"
                                               HorizontalAlignment="Left"
                                               local:ScreenReader.Event="OnChange"
                                               local:ScreenReader.LineType="SelectedItem"
                                               local:ScreenReader.SelectedNumber="{Binding (local:ScreenReader.SelectedNumber), RelativeSource={RelativeSource AncestorType={x:Type local:SpinnerControl}}}"
                                               local:ScreenReader.SelectedCount="{Binding (local:ScreenReader.SelectedCount), RelativeSource={RelativeSource AncestorType={x:Type local:SpinnerControl}}}"/>
                        </Grid>

                        <Grid x:Name="SpinnerContainer"
                              Grid.Column="1"
                              Margin="{StaticResource A_Margin_SpinnerTrailingMargin}">
                            <DockPanel>
                                <Grid x:Name="LeftArrowContainer"
                                      DockPanel.Dock="Left">
                                    <local:FZButton x:Name="LeftArrow"
                                                    Command="{TemplateBinding PrevSelectCommand}"
                                                    Style="{StaticResource A_Style_Button_SpinnerArrowButton}"
                                                    IsEnabled="{Binding LeftButtonState, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource H_Converter_SpinnerStateToEnabled}}">
                                        <Control Style="{StaticResource A_Style_Arrow_Left}"
                                                        HorizontalAlignment="Left"
                                                        Margin="-2,0,0,0" />
                                    </local:FZButton>
                                </Grid>

                                <Grid x:Name="RightArrowContainer"
                                      DockPanel.Dock="Right">
                                    <local:FZButton x:Name="RightArrow"
                                                    Command="{TemplateBinding NextSelectCommand}"
                                                    Style="{StaticResource A_Style_Button_SpinnerArrowButton}"
                                                    IsEnabled="{Binding RightButtonState, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource H_Converter_SpinnerStateToEnabled}}" >
                                        <Control Style="{StaticResource A_Style_Arrow_Right}"
                                                        HorizontalAlignment="Right"
                                                        Margin="0,0,-2,0" />
                                    </local:FZButton>
                                </Grid>
                                <Decorator HorizontalAlignment="Center">
                                    <FZTextBlock x:Name="FZTextBlock_SpinnerItemText" Style="{DynamicResource A_Style_FZTextBlock_SpinnerItem_Dynamic}"
                                        TextTrimming="CharacterEllipsis"
                                        TextAlignment="Left"
                                        HorizontalAlignment="Left"
                                        Stretch="None"
                                        Margin="10,0"
                                        UseLayoutRounding="False"
                                        local:ScreenReader.Event="OnChange"
                                        local:ScreenReader.LineType="SelectedValue"
                                        local:ScreenReader.SelectedNumber="{Binding SelectedIndex, RelativeSource={RelativeSource AncestorType={x:Type local:SpinnerControl}}, Converter={StaticResource A_IndexToNumberConverter}, FallbackValue=0}"
                                        local:ScreenReader.SelectedCount="{Binding ItemsSource.Count, RelativeSource={RelativeSource AncestorType={x:Type local:SpinnerControl}}, FallbackValue=0}"
                                        AutoScroll="{StaticResource H_AutoScrollSettings_SpinnerItemText}"
                                        AutoScroll.AllowScrolling="True"/>
                                </Decorator>
                            </DockPanel>
                        </Grid>
                    </Grid>


                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Color" TargetName="FZTextBlock_SpinnerLabelText" Value="{StaticResource A_Color_OptionsItem_Disabled}"/>
                            <Setter Property="Opacity" TargetName="FZTextBlock_SpinnerLabelText" Value="{StaticResource A_Double_OptionsItemOpacity_Disabled}"/>
                        </Trigger>
                        <Trigger Property="Tag" Value="Locked">
                            <Setter Property="Visibility" TargetName="SpinnerContainer" Value="Hidden"/>
                            <Setter Property="Color" TargetName="FZTextBlock_SpinnerLabelText" Value="{StaticResource A_Color_TextMenu_Text_Locked}"/>
                        </Trigger>
                        <Trigger Property="IsKeyboardFocusWithin" Value="True">
                            <Setter Property="Color" TargetName="FZTextBlock_SpinnerLabelText" Value="{StaticResource A_Color_OptionsItem_Focused}"/>
                            <Setter Property="local:ScreenReader.Line" TargetName="FZTextBlock_SpinnerLabelText" Value="{Binding Label, RelativeSource={RelativeSource TemplatedParent}}" />
                        </Trigger>
                        
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Color" TargetName="FZTextBlock_SpinnerItemText" Value="{StaticResource A_Color_OptionsItem_Disabled}"/>
                            <Setter Property="Opacity" TargetName="FZTextBlock_SpinnerItemText" Value="{StaticResource A_Double_OptionsItemOpacity_Disabled}"/>
                        </Trigger>
                        <Trigger Property="IsKeyboardFocusWithin" Value="True">
                            <Setter Property="Color" TargetName="FZTextBlock_SpinnerItemText" Value="{StaticResource A_Color_OptionsItem_Focused}"/>
                            <Setter Property="MaxWidth" TargetName="FZTextBlock_SpinnerItemText" Value="infinity"/>
                            <Setter Property="local:ScreenReader.Line" TargetName="FZTextBlock_SpinnerItemText" Value="{Binding Text, RelativeSource={RelativeSource Self}}" />
                            <Setter Property="TextTrimming" TargetName="FZTextBlock_SpinnerItemText" Value="None" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="A_Style_FZTextBlock_SpinnerTitle_Default" TargetType="FZTextBlock"
        BasedOn="{StaticResource A_Style_FZTextBlock_SpinnerTitle}">
        <Setter Property="Text" Value="{Binding Label, RelativeSource={RelativeSource TemplatedParent}}"/>
        <Setter Property="ScreenReader.ControlType" Value="Spinner"/>
    </Style>

    <Style x:Key="A_Style_FZTexBlock_SpinnerItem_Default" TargetType="FZTextBlock"
        BasedOn="{StaticResource A_Style_FZTextBlock_SpinnerItem}">
        <Setter Property="Text" Value="{Binding TemplatedParent.SelectedItem, RelativeSource={RelativeSource Self}}"/>
        <Setter Property="FontFamily" Value="Horizon_A_tf"/>
    </Style>

    <Style x:Key="A_Style_SpinnerControl_Default"
           BasedOn="{StaticResource A_Style_SpinnerControl_Default_Internal}"
           TargetType="local:SpinnerControl">
        <Style.Resources>
            <Style x:Key="A_Style_FZTextBlock_SpinnerTitle_Dynamic"
                   TargetType="local:FZTextBlock"
                   BasedOn="{StaticResource A_Style_FZTextBlock_SpinnerTitle_Default}">
            </Style>
            <Style x:Key="A_Style_FZTextBlock_SpinnerItem_Dynamic"
                   TargetType="local:FZTextBlock"
                   BasedOn="{StaticResource A_Style_FZTexBlock_SpinnerItem_Default}" />
        </Style.Resources>
    </Style>

    <Style x:Key="A_Style_SpinnerControl_Default_InItemsList"
           BasedOn="{StaticResource A_Style_SpinnerControl_Default}"
           TargetType="local:SpinnerControl">
        <Style.Resources>
            <Thickness x:Key="A_Thickness_SpinnerMargin_Dynamic">16,0</Thickness>
        </Style.Resources>
        <Setter Property="Height"
                Value="{StaticResource A_Double_TextMenu_Height_Default}" />
        <Setter Property="FocusSelf.WhenTrue"
                Value="{Binding IsFocused, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, FallbackValue=False}"/>
    </Style>

    <Style x:Key="A_Style_SpinnerControl_Default_InItemsList_Ellipsis"
           BasedOn="{StaticResource A_Style_SpinnerControl_Default_InItemsList}"
           TargetType="local:SpinnerControl">
    </Style>
</ResourceDictionary>