<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    DataContext="{Binding RelativeSource={RelativeSource Self}}"
    Style="{StaticResource A_Style_Page_Generic}"
    x:Class="ForzaUI.Scenes.Anthem.A_Stats">
    <Page.Resources>
        <ResourceDictionary>
            <AutoScrollSettings x:Key="A_AutoScrollSettings_StatLabels"
                                ScrollSeparation="100"
                                InitialPause="0:0:0.5"
                                Speed="40"
                                ScrollOrientation="Horizontal"
                                ApplyClip="True"/>

            <Style
                TargetType="local:FZTextBlock"
                x:Key="A_Style_FZTextBlock_Stats_Label">
                <Setter
                    Property="TextWrapping"
                    Value="NoWrap" />
                <Setter
                    Property="CapHeight"
                    Value="15" />
                <Setter
                    Property="FontFamily"
                    Value="Horizon_C" />
                <Setter
                    Property="Color"
                    Value="{StaticResource H_Color_Primary_White}" />
                <Setter
                    Property="Opacity"
                    Value="0.8" />
                <Setter
                    Property="TrackingAdjust"
                    Value="-0.005" />
                <Setter
                    Property="TextTrimming"
                    Value="CharacterEllipsis" />
                <Setter 
                    Property="ClipToBounds"
                    Value="False"/>
                <Setter
                    Property="Stretch"
                    Value="None"/>
                <Setter
                    Property="HorizontalAlignment"
                    Value="Stretch"/>
                <Setter
                    Property="AutoScroll"
                    Value="{StaticResource A_AutoScrollSettings_StatLabels}"/>
                <Setter
                    Property="AutoScroll.AllowScrolling"
                    Value="False"/>
                <Style.Triggers>
                    <DataTrigger
                        Binding="{Binding IsKeyboardFocused, RelativeSource={RelativeSource AncestorType={Type ContentControl}}}"
                        Value="True">
                        <Setter
                            Property="Opacity"
                            Value="1" />
                        <Setter Property="AutoScroll.AllowScrolling" Value="True"/>
                        <Setter Property="TextTrimming" Value="None" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            
            <Double x:Key="A_Double_StatsValueDefaultCapHeight">30</Double>
            
            <Style
                TargetType="local:FZTextBlock"
                x:Key="A_Style_FZTextBlock_Stats_Value_Small">
                <Setter
                    Property="Color"
                    Value="{StaticResource A_Color_Tile_Selected}" />
                <Setter
                    Property="CapHeight"
                    Value="{StaticResource A_Double_StatsValueDefaultCapHeight}" />
                <Setter
                    Property="FontFamily"
                    Value="Horizon_C" />
                <Setter
                    Property="Color"
                    Value="{StaticResource A_Color_StatsItem_Value}" />
                <Setter
                    Property="TextWrapping"
                    Value="NoWrap" />
                <Setter
                    Property="TextTrimming"
                    Value="CharacterEllipsis" />
                <Setter 
                    Property="ClipToBounds"
                    Value="False"/>
                <Setter
                    Property="Stretch"
                    Value="None"/>
                <Setter
                    Property="HorizontalAlignment"
                    Value="Stretch"/>
                <Setter
                    Property="AutoScroll"
                    Value="{StaticResource A_AutoScrollSettings_StatLabels}"/>
                <Setter
                    Property="AutoScroll.AllowScrolling"
                    Value="False"/>
                <Style.Triggers>
                    <DataTrigger
                        Binding="{Binding IsKeyboardFocused, RelativeSource={RelativeSource AncestorType={Type ContentControl}}}"
                        Value="True">
                        <Setter Property="AutoScroll.AllowScrolling" Value="True"/>
                        <Setter Property="TextTrimming" Value="None" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            <MappingConverter x:Key="A_LangStrToStatsValueCapHeight" Default="{StaticResource A_Double_StatsValueDefaultCapHeight}">
                <MappingConverterEntry Key="CHS" Value="44"/>
                <MappingConverterEntry Key="CHT" Value="44"/>
            </MappingConverter>
            <Style
                BasedOn="{StaticResource A_Style_FZTextBlock_Stats_Value_Small}"
                TargetType="local:FZTextBlock"
                x:Key="A_Style_FZTextBlock_Stats_Value">
                <Setter
                    Property="Color"
                    Value="{StaticResource H_Color_Primary_White}" />
                <Setter
                    Property="CapHeight"
                    Value="{Binding LangStr, Source={StaticResource PART_UISceneContext}, Converter={StaticResource A_LangStrToStatsValueCapHeight}}" />
            </Style>
            <Style
                TargetType="local:FZMaterial"
                x:Key="A_Style_FZMaterial_StatsLabelSeparatorLine">
                <Setter
                    Property="Color"
                    Value="#FFFFFF" />
                <Setter
                    Property="Opacity"
                    Value="0.2" />
                <Setter
                    Property="Height"
                    Value="3" />
                <Style.Triggers>
                    <DataTrigger
                        Binding="{Binding IsKeyboardFocused, RelativeSource={RelativeSource AncestorType={Type      ContentControl}}}"
                        Value="True"> 
                        <Setter
                            Property="Opacity"
                            Value="1" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            <Style
                x:Key="A_Style_CommonListBox_LargeScrollableNoticePanel_Stats"
                TargetType="{Type local:CommonListBox}"
                BasedOn="{StaticResource A_Style_CommonListBox_LargeScrollableNoticePanel}">
                <Setter
                    Property="local:BindingProxy.A">
                    <Setter.Value>
                        <Thickness>0,0,0,0</Thickness>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style
                x:Key="A_Style_FZMaterial_StatsType_Icon"
                TargetType="FZMaterial">
                <Setter Property="ImageSource"
                        Value="{Binding ItemType, Converter={StaticResource A_Converter_StatTypes_to_ImageSource}}"/>
                <Setter Property="Visibility"
                        Value="{Binding ItemType, Converter={StaticResource A_Converter_StatTypes_to_Image_Visibility}}"/>
            </Style>
            
            <Style
                x:Key="A_Style_FZMaterial_Stats_Background"
                TargetType="{Type local:FZMaterial}"
                BasedOn="{StaticResource A_Style_FZMaterial_FlatPanel_Tile}">
                <Setter
                    Property="Preset"
                    Value="{StaticResource H_GlassRoundtangle_Low_4px}" />
                <Setter
                    Property="Color"
                    Value="{StaticResource H_Color_Glass_Purple_40pc}" />
                <Style.Triggers>
                    <DataTrigger
                        Binding="{Binding IsKeyboardFocused, RelativeSource={RelativeSource AncestorType={Type      ContentControl}}}"
                        Value="True"> 
                        <Setter
                            Property="Color"
                            Value="{StaticResource H_Color_Primary_Black}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            
            <ControlTemplate
                TargetType="ListBoxItem"
                x:Key="A_ControlTemplate_Stat">
                <Grid x:Name="Grid_Container"
                      ScreenReader.Event="OnChange"
                      ScreenReader.LineType="SelectedItem"
                      ScreenReader.SelectedNumber="{Binding (VirtualizingWrapPanel.ItemIndex), FallbackValue=0, RelativeSource={RelativeSource AncestorType={Type ListBoxItem}}, Converter={StaticResource A_IndexToNumberConverter}}"
                      ScreenReader.SelectedCount="{Binding Items.Count, FallbackValue=0, RelativeSource={RelativeSource AncestorType={Type Selector}}}"
                      >
                    <FZMaterial Style="{StaticResource A_Style_FZMaterial_Stats_Background}"
                                Height="140"
                                Width="572"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Top">
                        <Grid Margin="10,7">
                            <DockPanel LastChildFill="True">
                                <StackPanel
                                    DockPanel.Dock="Top"
                                    Orientation="Vertical">
                                    <FZTextBlock
                                        Style="{StaticResource A_Style_FZTextBlock_Stats_Label}"
                                        Text="{Binding ItemTitle}"
                                        Margin="5,13,0,0"
                                        HorizontalAlignment="Left"/>
                                    <FZMaterial
                                        Margin="0,9"
                                        Style="{StaticResource A_Style_FZMaterial_StatsLabelSeparatorLine}"
                                        />
                                </StackPanel>
                                <DockPanel LastChildFill="True"
                                            Margin="0,0,0,10">
                                    <FZMaterial DockPanel.Dock="Left"
                                                Width="48"
                                                Height="48"
                                                Margin="3,0,7,2"
                                                VerticalAlignment="Center"
                                                Style="{StaticResource A_Style_FZMaterial_StatsType_Icon}"/>
                                    <FZTextBlock
                                        Style="{StaticResource A_Style_FZTextBlock_Stats_Value}"
                                        Text="{Binding ItemValue}"
                                        Margin="5,0,0,2"
                                        VerticalAlignment="Center"
                                        x:Name="ValueText" />
                                </DockPanel>
                            </DockPanel>
                        </Grid>
                    </FZMaterial>
                    <StrokeHighlightControl Style="{StaticResource H_Style_StrokeHighlight_Instant_TextMenu}"
                                            Height="140"
                                            Width="572"
                                            HorizontalAlignment="Left"
                                            VerticalAlignment="Top"
                                            ContentRadius="4"
                                            IsEnabled="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource TemplatedParent}}"/>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsKeyboardFocused"
                             Value="True">
                        <Setter Property="local:ZPanel.ZIndex" Value="1" />
                        <Setter Property="local:ZPanel.ClippingBias" Value="1" />
                        <Setter TargetName="Grid_Container"
                            Property="local:ScreenReader.Line"
                            Value="{Binding ItemScreenReaderText}"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
            <Style
                TargetType="{Type ListBoxItem}"
                x:Key="A_Style_ListBoxItem_Stat">
                <Setter
                    Property="Template"
                    Value="{StaticResource A_ControlTemplate_Stat}" />
                <Setter
                    Property="FocusSelf.WhenTrue"
                    Value="{Binding (Selector.IsSelected), RelativeSource={RelativeSource Self}}" />
                <Setter
                    Property="local:FocusOnMouseOverBehaviour.Self"
                    Value="True" />
            </Style>
        </ResourceDictionary>
    </Page.Resources>
    <UIPageTransitionManager.TransitionManager>
        <UIPageTransitionManager
            Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}" />
    </UIPageTransitionManager.TransitionManager>
    <Grid>
        <Control
            Style="{StaticResource A_Style_Control_ScreenBackground}" />
        <PlayerBarControl
            Style="{StaticResource A_Style_PlayerBarControl}"
            x:Name="TopBar" />
        <ContentControl
            Style="{StaticResource A_Style_ButtonBar}"
            x:Name="BottomBar">
            <ContentControl
                Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}"
                ControllerButtonPanel.BDescription="{Loc HelpButtons.IDS_Back}"
                x:Name="PART_DefaultHelpPanel" />
        </ContentControl>
        <Border
            Style="{StaticResource A_Style_Border_ScenePadding}"
            x:Name="PART_LayoutRoot">
            <Grid
                Style="{StaticResource A_Style_FrameworkElement_ScreenTilt}">
                <StackPanel
                    HorizontalAlignment="Left"
                    Orientation="Vertical"
                    VerticalAlignment="Stretch"
                    Margin="19,7,0,0">
                    <Decorator
                        HorizontalAlignment="Left"
                        Margin="0,50,0,0"
                        Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                        <ContentControl
                            Content="{Binding Title}"
                            Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                            Width="364"
                            Margin="0,0,0,10"
                            BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Stats.png" />
                    </Decorator>
                    <Decorator
                        Focusable="False"
                        HorizontalAlignment="Left"
                        Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_1}"
                        VerticalAlignment="Top">
                        <FZTabButtonsSelector
                            ItemsSource="{Binding Categories}"
                            SelectedIndex="0"
                            Style="{StaticResource H_Style_TabBar}"
                            x:Name="PART_ItemsSelector_Category"
                            Margin="0,0,0,10" />
                    </Decorator>
                    <Grid
                        Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_2}"
                        Opacity="1"
                        Margin="0">
                        <WrapListBox
                            Template="{StaticResource H_ControlTemplate_Carousel_Default}"
                            Height="716"
                            DataContext="{Binding SelectedItem, ElementName=PART_ItemsSelector_Category}"
                            ItemHeight="144"
                            ItemWidth="577"
                            WrapSelection="True"
                            HorizontalAlignment="Left"
                            OverrideAcrossNavigation="True"
                            ScrollOrientation="Vertical"
                            ItemContainerStyle="{StaticResource A_Style_ListBoxItem_Stat}"
                            EmptyItemStyle="{x:Null}"
                            ItemsSource="{Binding ListData}"
                            FocusOnPageFocusGained.SelectorSelectedItem="True"    
                            SelectedIndex="0"
                            VerticalAlignment="Top"
                            x:Name="PART_CommonListBox_StatsList" />
                        <ScrollBar
                                x:Name="PART_ScrollBar_StatsList"
                                HorizontalAlignment="Right"
                                Margin="0,0,3,0"
                                Style="{StaticResource A_Style_ScrollBar_Default}"
                                Minimum="{Binding ScrollWindowMin, ElementName=PART_CommonListBox_StatsList}"
                                Maximum="{Binding ScrollWindowMax, ElementName=PART_CommonListBox_StatsList}"
                                Value="{Binding ScrollWindowValue, ElementName=PART_CommonListBox_StatsList, Mode=TwoWay}"
                                ViewportSize="{Binding ScrollWindowSize, ElementName=PART_CommonListBox_StatsList}" />
                    </Grid>
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</Page>