<Page x:Class="ForzaUI.Scenes.Anthem.A_RivalsDestinationSelect"
      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:System="clr-namespace:System;assembly=mscorlib"
      mc:Ignorable="d"
      xmlns:local="clr-namespace:ForzaUI;assembly="
      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>

    <System:Double x:Key="A_Double_RivalsRaceDiscipline_Tile_Width">572</System:Double>
    <System:Double x:Key="A_Double_RivalsRaceDiscipline_Tile_Width_withSpacing">576</System:Double>
    <System:Double x:Key="A_Double_RivalsRaceDiscipline_Tile_Height">284</System:Double>
    <System:Double x:Key="A_Double_RivalsRaceDiscipline_Tile_Height_withSpacing">288</System:Double>
    <System:Double x:Key="A_Double_RivalsRaceDiscipline_ListBox_Width">2880</System:Double>

        <ControlTemplate x:Key="A_ControlTemplate_ContentControl_ItemTile" TargetType="ContentControl">
            <Grid>

                <Decorator >
                    <local:FZMaterial x:Name="DropShadow"
                                  Style="{StaticResource A_Style_FZMaterial_ShadowBase_ForSubgraph}"
                                  Margin="-24"
                                  IsHitTestVisible="False"
                                  Visibility="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}" />
                </Decorator>
                <Decorator  HorizontalAlignment="Center" VerticalAlignment="Center"
                        Visibility="Visible">
                    <Grid>
                        <Control Template="{StaticResource A_ControlTemplate_RivalsDestinationTile}"                           
                                     Width="{StaticResource A_Double_RivalsRaceDiscipline_Tile_Width}"
                                     Height="{StaticResource A_Double_RivalsRaceDiscipline_Tile_Height}" 
                                     VerticalAlignment="Center" />
                    </Grid>
                </Decorator>
                
                <Grid x:Name="ScaledContainer"
                      Width="{StaticResource A_Double_RivalsRaceDiscipline_Tile_Width}"
                      Height="{StaticResource A_Double_RivalsRaceDiscipline_Tile_Height}">
                    <Control Style="{StaticResource H_Style_TemplatedElement_MouseRollover_ListBoxItem}" />

                    <StrokeHighlightControl x:Name="FocusHighlight"
                                            Style="{StaticResource H_Style_StrokeHighlight_Animated}"
                                            ContentRadius="4"
                                            IsEnabled="{Binding (Selector.IsSelected), FallbackValue=False, RelativeSource={RelativeSource TemplatedParent}}"/>
                    <Grid Width="{StaticResource A_Double_RivalsRaceDiscipline_Tile_Width}">
                        <local:AudioEvent x:Name="Audio" />
                        <local:RoutedEventCommand x:Name="ClickOnMouseItem"
                                                    RoutedEvent="UIElement.MouseLeftButtonDown"/>
                        <local:FZMaterial Color="#00000000"
                                            x:Name="HitTestHelper"
                                            local:RoutedEventCommand.Action="{Binding ElementName=ClickOnMouseItem}"/>
                    </Grid>
                </Grid>
            </Grid>
             <ControlTemplate.Triggers>
                <DataTrigger Binding="{Binding (Selector.IsSelected), RelativeSource={RelativeSource Self}}"
                                 Value="True">
                    <Setter TargetName="ClickOnMouseItem" Property="Command" Value="{Binding SelectCommand, RelativeSource={RelativeSource AncestorType=Page}}"/>
                    <Setter Property="local:ZPanel.ZIndex" Value="1" />
                </DataTrigger>
            </ControlTemplate.Triggers> 
        </ControlTemplate>
 
        <Style x:Key="A_Style_ListBoxItem_ItemTile" TargetType="ListBoxItem">
            <Setter Property="Width" Value="{StaticResource A_Double_RivalsRaceDiscipline_Tile_Width}" />
            <Setter Property="Focusable" Value="True" />
            <Setter Property="Template" Value="{StaticResource A_ControlTemplate_ContentControl_ItemTile}" />
            <Setter Property="local:ZPanel.DisableClipping" Value="True" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsSelectable}" Value="False" >
                    <Setter Property="Focusable" Value="False" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Page.Resources>

    <Grid>
        <!-- Background Blur -->
       <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />

        <local:PlayerBarControl x:Name="TopBar" Style="{StaticResource A_Style_PlayerBarControl}" />
        <ContentControl Style="{StaticResource A_Style_ButtonBar}"
                        Width="Auto">
            <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_Border_ScenePadding}">
            <Grid x:Name="PART_LayoutRoot" KeyboardNavigation.DirectionalNavigation="Contained">
                <Grid Style="{StaticResource A_Style_FrameworkElement_ScreenTilt}" Margin="20,-24,0,0">
                    <StackPanel Orientation="Vertical"
                                VerticalAlignment="Center"
                                HorizontalAlignment="Center">
                        <StackPanel Orientation="Horizontal"
                                    Margin="0,0"
                                    Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                            <ContentControl Content="{local:Loc ScreenTitles.IDS_Rivals_DisciplineSelect_Title}"
                                            Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                            local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Rivals.png"
                                            Width="364"
                                            Margin="0,0,0,5"/>
                        </StackPanel>
                        <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                            <local:WrapListBox x:Name="PART_ItemListBox"
                                               Focusable="False"
                                               Height="576"
                                               Width="{StaticResource A_Double_RivalsRaceDiscipline_ListBox_Width}"
                                               AllowMouseWheelScrolling="False"
                                               OverrideAcrossNavigation="True"
                                               Template="{StaticResource A_ControlTemplate_Carousel_Default}"
                                               ScrollOrientation="Horizontal"
                                               WrapSelection="True"
                                               ItemWidth="{StaticResource A_Double_RivalsRaceDiscipline_Tile_Width_withSpacing}"
                                               ItemHeight="{StaticResource A_Double_RivalsRaceDiscipline_Tile_Height_withSpacing}"
                                               PageSize="1"
                                               SelectionLimitTop="{StaticResource A_Double_RivalsRaceDiscipline_Tile_Width_withSpacing}"
                                               SelectionLimitBottom="{StaticResource A_Double_RivalsRaceDiscipline_Tile_Width_withSpacing}"
                                               ItemContainerStyle="{StaticResource A_Style_ListBoxItem_ItemTile}"
                                               ItemsSource="{Binding Collection}"
                                               SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                                               local:FocusOnPageFocusGained.SelectorSelectedItem="True"
                                               Panel.ZIndex="1"
                                               HorizontalAlignment="Center"
                                               Margin="-25,0,0,0">
                                <local:WrapListBox.EmptyItemStyle>
                                    <Style TargetType="Control" />
                                </local:WrapListBox.EmptyItemStyle>
                            </local:WrapListBox>
                        </Grid>

                    </StackPanel>
                </Grid>
            </Grid>
        </Border>
    </Grid>
</Page>
