<QuickChatContextSelect x:Class="ForzaUI.Scenes.Anthem.A_QuickChatContextSelect"
      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:ForzaUI"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      mc:Ignorable="d" 
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}"/>
    </local:UIPageTransitionManager.TransitionManager>

    <Page.Resources>
        <ResourceDictionary>
            <Style x:Key="A_Style_ListBoxItem_QuickChatSlotItem"
                BasedOn="{StaticResource A_Style_ListBoxItem_TextMenu_Gaps}"
                TargetType="ListBoxItem">
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="Margin" Value="0,0,0,4"/>
            </Style>

            <Style x:Key="A_Style_ControllerButtonControl_QuickChatSlotInput"
                TargetType="{x:Type local:ControllerButtonControl}"
                BasedOn="{StaticResource A_Style_ControllerButtonControl_Standalone}">
                <Setter Property="Margin" Value="24,0,12,0"/>
                <Setter Property="Height" Value="40"/>
                <Setter Property="UseLargeIcon" Value="True"/>
                <Setter Property="HideBackground" Value="True"/>
                <Setter Property="HideShadow" Value="True"/>
                <Setter Property="AllowMouseClick" Value="False"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Input}" Value="{x:Null}">
                        <Setter Property="Visibility" Value="{x:Static Visibility.Collapsed}"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <DataTemplate x:Key="A_DataTemplate_ListBoxItem_QuickChatSlotItem">
                <Grid IsHitTestVisible="False" Height="50" >
                    <DockPanel>
                        <local:ControllerButtonControl x:Name="ControllerButton" DockPanel.Dock="Left"
                                Style="{StaticResource A_Style_ControllerButtonControl_QuickChatSlotInput}"
                                InputOverride="{Binding Input}"
                                SupportsControllerInput="True"
                                HorizontalAlignment="Left"
                                local:ScreenReader.Event="OnChange"
                                local:ScreenReader.LineType="SelectedItem"
                                local:ScreenReader.ControlType="Button"
                                local:ScreenReader.SelectedNumber="{Binding ButtonIndex, Converter={StaticResource A_IndexToNumberConverter}}"
                                local:ScreenReader.SelectedCount="{Binding ButtonCount}" />
                        <local:FZTextBlock x:Name="Text" Text="{Binding Text}"
                                Style="{StaticResource A_Style_FZTextBlock_OptionText}"
                                Margin="0"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Center"
                                FontFamily="Horizon_B"
                                local:ScreenReader.Event="OnChange"
                                local:ScreenReader.LineType="SelectedValue" />
                    </DockPanel>
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Tag, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="GroupHeader">
                        <Setter TargetName="Text"
                                Property="TextAlignment"
                                Value="Center" />
                        <Setter TargetName="Text"
                                Property="FontFamily"
                                Value="Horizon_A" />
                        <Setter TargetName="Text"
                                Property="Text"
                                Value="{Binding ContextName}" />
                        <Setter TargetName="Text"
                                Property="Color"
                                Value="{StaticResource A_Color_TextMenu_Text_Highlighted}" />
                        <Setter TargetName="ControllerButton"
                                Property="Visibility"
                                Value="Collapsed" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True">
                        <Setter TargetName="Text" Property="local:ScreenReader.Line" Value="{Binding Text}" />
                        <Setter TargetName="ControllerButton" Property="local:ScreenReader.Line" Value="{Binding ScreenReaderName, RelativeSource={RelativeSource Self}}" />
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <Style x:Key="A_Style_ListBoxItem_QuickChatSlotItem_Header"
                BasedOn="{StaticResource A_Style_ListBoxItem_TextMenu_Gaps}"
                TargetType="ListBoxItem">
                <Setter Property="Focusable"
                        Value="False" />
                <Setter Property="Tag"
                        Value="GroupHeader" />
                <Setter Property="Height"
                        Value="50" />
                <Setter Property="Margin"
                        Value="0,0,0,4"/>
                <Setter Property="Width"
                        Value="668" />
                <Setter Property="ContentTemplate"
                        Value="{StaticResource A_DataTemplate_ListBoxItem_QuickChatSlotItem}"/>
                <Setter
                        Property="Template">
                        <Setter.Value>
                            <ControlTemplate
                                TargetType="ContentControl">
                                <FZMaterial
                                    Style="{StaticResource H_Style_Container_GlassHighBlur_Description}">
                                    <Grid>
                                        <ContentPresenter
                                            Margin="0,0,0,0"
                                            Panel.ZIndex="{DynamicResource A_Int32_Icon_ZIndex}" />
                                    </Grid>
                                </FZMaterial>
                                <ControlTemplate.Triggers>
                                    <Trigger
                                        Property="Content"
                                        Value="{Null}">
                                        <Setter
                                            Property="Visibility"
                                            Value="Collapsed" />
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
            </Style>

        </ResourceDictionary>
    </Page.Resources>

    <Grid>
       <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />
        <local:PlayerBarControl x:Name="TopBar"
                                Style="{StaticResource A_Style_PlayerBarControl}"
                                Visibility="{Binding IsInPauseFlow, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
        <ContentControl x:Name="BottomBar"
                            Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl x:Name="PART_DefaultHelpPanel"
                            local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Select}"
                            local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                            Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}"/>
        </ContentControl>
        <Border Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}"
                SnapsToDevicePixels="True"
                UseLayoutRounding="True">
            <StackPanel
                x:Name="MainContent"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                <ContentControl
                    Content="{local:Loc ScreenTitles.IDS_QuickChatSelect}"
                    Style="{StaticResource A_Style_ContentControl_PopupTitleBlock}" />
                <DockPanel Margin="20,0,0,0">
                    <ScrollBar Style="{StaticResource A_Style_ScrollBar_Default}"
                               DockPanel.Dock="Right"
                               Minimum="{Binding ScrollWindowMin, ElementName=OptionsList}"
                               Maximum="{Binding ScrollWindowMax, ElementName=OptionsList}"
                               Value="{Binding ScrollWindowValue, ElementName=OptionsList, Mode=TwoWay}"
                               ViewportSize="{Binding ScrollWindowSize, ElementName=OptionsList}"
                               Margin="10,0,0,0">
                    </ScrollBar>
                    <WrapListBox x:Name="OptionsList"
                                 Template="{StaticResource H_ControlTemplate_TextMenu_Default}"
                                 SeparatorPlacement="{XAMLVWPSeparatorPlacement ContextName, InitialSeparator=True}"
                                 ScrollOrientation="Vertical"
                                 ItemHeight="54"
                                 ItemWidth="668"
                                 SelectionLimitTop="54"
                                 SelectionLimitBottom="0"
                                 ItemContainerStyle="{StaticResource A_Style_ListBoxItem_QuickChatSlotItem}"
                                 ItemTemplate="{StaticResource A_DataTemplate_ListBoxItem_QuickChatSlotItem}"
                                 ItemsSource="{Binding Collection}"
                                 SelectedIndex="0"
                                 SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType=Page}, Mode=OneWayToSource}"
                                 Height="648"
                                 Width="668"
                                 EmptyItemStyle="{x:Null}"
                                 local:FocusOnPageFocusGained.SelectorSelectedItem="True"
                                 local:ManualPassthroughProperty.Input="{Binding SelectedItem, RelativeSource={RelativeSource Self}}"
                                 local:ManualPassthroughProperty.Allowed="{Binding SelectedItem, RelativeSource={RelativeSource Self}, Converter={StaticResource A_Converter_TrueIfNotNull}, FallbackValue={StaticResource A_Boolean_False}}"
                                 local:ScreenReader.LineType="SelectedGroup"
                                 local:ScreenReader.Event="OnChange"
                                 local:ScreenReader.Line="{Binding (local:ManualPassthroughProperty.LastValidAllowedOutput).ContextName, RelativeSource={RelativeSource Self}}"
                                 local:ScreenReader.SelectedNumber="{Binding (local:ManualPassthroughProperty.LastValidAllowedOutput).ContextIndex, RelativeSource={RelativeSource Self}, Converter={StaticResource A_IndexToNumberConverter}}"
                                 local:ScreenReader.SelectedCount="{Binding (local:ManualPassthroughProperty.LastValidAllowedOutput).ContextCount, RelativeSource={RelativeSource Self}}">
                        <DynamicData.Data>
                            <DynamicDataSource>
                                <DynamicDataItem Name="WrapListBox_SeparatorItemStyle" DataType="{x:Type Style}" Value="{StaticResource A_Style_ListBoxItem_QuickChatSlotItem_Header}" />
                            </DynamicDataSource>
                        </DynamicData.Data>
                        <WrapListBox.Resources>
                            <Thickness x:Key="A_Margin_VirtualizingWrapPanel">0,0</Thickness>
                        </WrapListBox.Resources>
                    </WrapListBox>
                </DockPanel>
            </StackPanel>
        </Border>
    </Grid>
</QuickChatContextSelect>
