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

        <!-- Template for restrictions elements that are shown as a string -->
        <DataTemplate DataType="{x:Type System:String}">
            <DockPanel>
                <local:FZTextBlock Text="{Binding}" Style="{StaticResource A_Style_FZTextBlock_RivalsRouteDistanceLarge}"/>
                <local:FZTextBlock DockPanel.Dock="Right" Text="/" Margin="9,0" Style="{StaticResource A_Style_FZTextBlock_RivalsRouteDistanceLarge}" />
            </DockPanel>
        </DataTemplate>

        <!-- Template for restrictions elements that are shown as a string -->
        <ItemsPanelTemplate x:Key="A_Template_RestrictionsPanel">
            <WrapPanel IsItemsHost="True" />
        </ItemsPanelTemplate>

        <Style x:Key="A_Style_FZMaterial_DetailsDivider" TargetType="local:FZMaterial" BasedOn="{StaticResource A_Style_FZMaterial_GlassPanel_HorizontalDivider}">
            <Setter Property="Color" Value="{StaticResource H_Color_Primary_White}"/>
            <Setter Property="Opacity" Value="0.4"/>
            <Setter Property="Margin" Value="8,0"/>
        </Style>

        <Style TargetType="{x:Type local:FZRun}" x:Key="A_Style_FZRun_Details_HIGHLIGHT">
            <Setter Property="Color" Value="{StaticResource H_Color_Primary_Green}"/>
            <Setter Property="FontFamily" Value="Horizon_C"/>
        </Style>

        <MappingConverter x:Key="A_MappingConverter_Details">
            <MappingConverterEntry Key="{NoCase HIGHLIGHT}" Value="{StaticResource A_Style_FZRun_Details_HIGHLIGHT}" />
        </MappingConverter>

        <Style TargetType="local:FZTextBlock"
               x:Key="A_Style_FZTextBlock_RivalDetailsHeader"
               BasedOn="{StaticResource A_Style_FZTextBlock_DescriptionBlockBody}">
            <Setter Property="CapHeight" Value="18"/>
            <Setter Property="FontFamily" Value="Horizon_B"/>
            <Setter Property="TextWrapping" Value="Wrap"/>
            <Setter Property="LineAdjust" Value="-0.5"/>
            <Setter Property="Color" Value="{StaticResource H_Color_Primary_Grey_80pc}"/>
        </Style>
        <Style TargetType="local:FZTextBlock"
               x:Key="A_Style_FZTextBlock_RivalDetails"
               BasedOn="{StaticResource A_Style_FZTextBlock_DescriptionBlockBody}">
            <Setter Property="CapHeight" Value="18"/>
            <Setter Property="FontFamily" Value="Horizon_A"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>

        <Style x:Key="A_Style_HideIfNoTargetTime" TargetType="FrameworkElement">
            <Setter Property="Visibility"
                    Value="Hidden" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding SelectedItem.RivalInfo.HasTarget, RelativeSource={RelativeSource AncestorType=Page}}"
                             Value="True">
                    <DataTrigger.Setters>
                        <Setter Property="Visibility"
                                Value="Visible" />
                    </DataTrigger.Setters>
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="A_Style_FZTextBlock_AutoScroll_Description" BasedOn="{StaticResource A_Style_FZTextBlock_DescriptionBlockBody}" TargetType="local:FZTextBlock">
            <Setter Property="Color" Value="{StaticResource A_Color_Body_Text}" />
            <Setter Property="TextWrapping" Value="Wrap" />
            <Setter Property="CapHeight" Value="13" />
            <Setter Property="MarkupConverter" Value="{StaticResource A_MappingConverter_Details}" />
            <Setter Property="Text" Value="{Binding Description}" />
            <Setter Property="Margin" Value="{Binding LangStr, Source={StaticResource PART_UISceneContext}, Converter={StaticResource A_LangStrToAutoScrollMargin}}" />
            <Setter Property="ClipToBounds" Value="True" />
            <Setter Property="AutoScroll" Value="{StaticResource H_AutoScrollSettings_Descriptions}" />
            <Setter Property="AutoScroll.AllowScrolling" Value="True" />
        </Style>

        <Style TargetType="FrameworkElement"
               x:Key="A_Style_FrameworkElement_SelectedTrackComparison">
            <Setter Property="local:MultiDataConversion.TargetType" Value="{x:Type Int32}" />
            <Setter Property="local:MultiDataConversion.Value" Value="{Binding ActiveTrack, RelativeSource={RelativeSource AncestorType=Page}}" />
            <Setter Property="local:MultiDataConversion.Parameter" Value="{Binding MediaTrack}" />
            <Setter Property="local:MultiDataConversion.Converter" Value="{StaticResource A_CompareConverter}" />
        </Style>
        <Style TargetType="FrameworkElement"
               x:Key="A_Style_FrameworkElement_HiddenIfSelectedItemTrackDoesntMatch"
               BasedOn="{StaticResource A_Style_FrameworkElement_SelectedTrackComparison}">
            <Setter Property="Visibility" Value="Collapsed" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding (local:MultiDataConversion.Output), RelativeSource={RelativeSource Self}}"
                             Value="0">
                    <Setter Property="Visibility"
                            Value="Visible" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
        <Style TargetType="FrameworkElement"
               x:Key="A_Style_FrameworkElement_HiddenIfSelectedItemTrackMatches"
               BasedOn="{StaticResource A_Style_FrameworkElement_SelectedTrackComparison}">
            <Setter Property="Visibility" Value="Visible" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding (local:MultiDataConversion.Output), RelativeSource={RelativeSource Self}}"
                             Value="0">
                    <Setter Property="Visibility"
                            Value="Collapsed" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
        <local:MappingConverter x:Key="A_Converter_TrackToCoverImage" Default="/ForzaUI;component/Textures/Data_Bound/Rivals/HendrixLarge.png">
            <local:MappingConverterEntry Key="{x:Static local:XAMLTrack.ExpansionOne}" Value="/ForzaUI;component/Textures/Data_Bound/Rivals/ExpansionOneLarge.png" />
            <local:MappingConverterEntry Key="{x:Static local:XAMLTrack.ExpansionTwo}" Value="/ForzaUI;component/Textures/Data_Bound/Rivals/ExpansionTwoLarge.png" />
        </local:MappingConverter>
        <Style TargetType="local:FZMaterial"
               x:Key="A_Style_FZMaterial_HiddenIfNotLoaded"
               BasedOn="{StaticResource A_Style_FrameworkElement_SelectedTrackComparison}">
            <Setter Property="Visibility" Value="Hidden" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding Downloaded, RelativeSource={RelativeSource Self}}"
                             Value="True">
                    <Setter Property="Visibility"
                            Value="Visible" />
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="A_Style_ContentControl_Carousel_ContainerStyle_Rivals" TargetType="ContentControl" BasedOn="{StaticResource H_Style_ContentControl_Carousel_ContainerStyle}">
            <Setter Property="Margin" Value="0,0,4,4" />
        </Style>

        <!-- BindingProxy.A - Text -->
        <!-- BindingProxy.B - IsEnabled -->
        <ControlTemplate x:Key="A_ControlTemplate_RivalCarProperties_Radio"
            TargetType="Control">
            <StackPanel Orientation="Vertical"
                        HorizontalAlignment="Center">
                <local:FZTextBlock Text="{Binding (local:BindingProxy.A), RelativeSource={RelativeSource TemplatedParent}}"
                                   Style="{StaticResource A_Style_FZTextBlock_RivalDetailsHeader}"
                                   HorizontalAlignment="Center"/>
                <local:FZMaterial x:Name="StateIcon"
                                  ImageSource="/ForzaUI;component/Textures/Data_Bound/Checkbox/Radio_Off.png"
                                  Width="43"
                                  Height="43"
                                  HorizontalAlignment="Center"/>
            </StackPanel>
            <ControlTemplate.Triggers>
                <DataTrigger Binding="{Binding (local:BindingProxy.B), RelativeSource={RelativeSource Self}}"
                    Value="True">
                    <Setter TargetName="StateIcon" Property="ImageSource" Value="/ForzaUI;component/Textures/Data_Bound/Checkbox/Radio_On.png" />
                </DataTrigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>

        <Style x:Key="A_Style_FZMaterial_AssistsIconABS_White" TargetType="local:FZMaterial">
            <Setter Property="Visibility" Value="Collapsed" />
            <Setter Property="Height" Value="43" />
            <Setter Property="Width" Value="43" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Data_Bound/Checkbox/Radio_On.png" />
            <Setter Property="Color" Value="{StaticResource H_Color_Primary_White}" />
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding UsedABS}" Value="True"/>
                        <Condition Binding="{Binding UsedAutoBrake}" Value="False"/>
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Visibility" Value="Visible" />
                </MultiDataTrigger>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding UsedABS}" Value="False"/>
                        <Condition Binding="{Binding UsedAutoBrake}" Value="False"/>
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Visibility" Value="Visible" />
                    <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Data_Bound/Checkbox/Radio_Off.png" />
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="A_Style_FZTextBlock_AssistsIconAutoBrake_White" TargetType="local:FZTextBlock">
            <Setter Property="Visibility" Value="Collapsed" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="CapHeight" Value="18" />
            <Setter Property="Margin" Value="0,9,0,0" />
            <Setter Property="Color" Value="{StaticResource H_Color_Primary_White}" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding UsedAutoBrake}" Value="True">
                    <Setter Property="Visibility" Value="Visible" />
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="A_Style_FZTextBlock_RivalName"
               TargetType="local:FZTextBlock"
               BasedOn="{StaticResource A_Style_FZTextBlock_RivalDetails}">
            <Setter Property="Text" Value="{local:Loc Rivals.IDS_NoCurrentRival}" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding RivalInfo.HasTarget}" Value="True">
                    <Setter Property="Text" Value="{Binding RivalInfo.UserProfile.FormattedGamertag}" />
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <ControlTemplate x:Key="A_ControlTemplate_ABS_White">
            <Grid>
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_AssistsIconABS_White}" />
                <local:FZTextBlock Text="A" Style="{StaticResource A_Style_FZTextBlock_AssistsIconAutoBrake_White}" />
            </Grid>
        </ControlTemplate>


        <Style
        x:Key="H_Style_AutoScrollPanel"
        TargetType="AutoScrollPanel">
        <Setter
            Property="ScrollType"
            Value="Speed" />
        <Setter
            Property="ScrollSeparation"
            Value="50" />
        <Setter
            Property="Speed"
            Value="20.0" />
        <Setter
            Property="ClipToBounds"
            Value="True" />
        <Setter
            Property="Focusable"
            Value="False" />
        <Setter
            Property="IsEnabled"
            Value="False" />
        <Setter
            Property="Orientation"
            Value="Vertical" />
        <Setter
            Property="AllowScrolling"
            Value="True" />
        <Setter
            Property="AnimationContext"
            Value="{Binding Content, RelativeSource={RelativeSource Self}}" />
        
        <Setter
            Property="Template">
            <Setter.Value>
                <ControlTemplate
                    TargetType="AutoScrollPanel">
                    <CommonListBox
                        Focusable="False"
                        ScrollViewer.VerticalScrollBarVisibility="Auto">
                        <CommonListBox.Template>
                            <ControlTemplate
                                TargetType="{Type ListBox}">
                                <ItemsPresenter />
                            </ControlTemplate>
                        </CommonListBox.Template>
                        <CommonListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel
                                    Orientation="{Binding Orientation, RelativeSource={RelativeSource FindAncestor, AncestorType=AutoScrollPanel}}"
                                    IsItemsHost="True"
                                    Focusable="False" />
                            </ItemsPanelTemplate>
                        </CommonListBox.ItemsPanel>
                        <CommonListBox.ItemContainerStyle>
                            <Style
                                TargetType="{Type ListBoxItem}">
                                <Setter
                                    Property="HorizontalContentAlignment"
                                    Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType=AutoScrollPanel}}" />
                                <Setter
                                    Property="Focusable"
                                    Value="False" />
                                <Setter
                                    Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate
                                            TargetType="ListBoxItem">
                                            <ContentPresenter
                                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </CommonListBox.ItemContainerStyle>
                        <ContentPresenter
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            Content="{TemplateBinding Content}" />
                        <Decorator
                            x:Name="Separator1"
                            Visibility="{Binding RequiresScrolling, RelativeSource={RelativeSource TemplatedParent}, Converter={FZBooleanToVisibilityConverter}}" />
                        <ContentPresenter
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            Content="{TemplateBinding Content}"
                            Visibility="{Binding RequiresScrolling, RelativeSource={RelativeSource TemplatedParent}, Converter={FZBooleanToVisibilityConverter}}" />
                        <Decorator
                            x:Name="Separator2"
                            Visibility="{Binding RequiresScrolling, RelativeSource={RelativeSource TemplatedParent}, Converter={FZBooleanToVisibilityConverter}}" />
                    </CommonListBox>
                    <ControlTemplate.Triggers>
                        <Trigger
                            Property="Orientation"
                            Value="Horizontal">
                            <Setter
                                TargetName="Separator1"
                                Property="Width"
                                Value="{Binding ScrollSeparation, RelativeSource={RelativeSource TemplatedParent}}" />
                            <Setter
                                TargetName="Separator2"
                                Property="Width"
                                Value="{Binding ScrollSeparation, RelativeSource={RelativeSource TemplatedParent}}" />
                        </Trigger>
                        <Trigger
                            Property="Orientation"
                            Value="Vertical">
                            <Setter
                                TargetName="Separator1"
                                Property="Height"
                                Value="{Binding ScrollSeparation, RelativeSource={RelativeSource TemplatedParent}}" />
                            <Setter
                                TargetName="Separator2"
                                Property="Height"
                                Value="{Binding ScrollSeparation, RelativeSource={RelativeSource TemplatedParent}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    </Page.Resources>

    <Grid>
        <local:MappingConverterResourcePreloader Converter="{StaticResource A_Converter_TrackToCoverImage}" ValueType="BitmapImage" />

        <!-- 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 Margin="44,0">
                <Grid Style="{StaticResource A_Style_FrameworkElement_ScreenTilt}">
                    <Grid>
                        <StackPanel Orientation="Vertical"
                                    VerticalAlignment="Center">
                            <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition}"
                                  local:UIPageTransitionManager.TransitionIndex="1">
                                <ContentControl x:Name="TitleBlock"
                                                Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                                local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Rivals.png"
                                                Content="{Binding Title}"
                                                Width="364"
                                                HorizontalAlignment="Left" />
                            </Grid>
                            <DockPanel DataContext="{Binding SelectedItem, ElementName=PART_List}"
                                       Style="{StaticResource A_Style_FrameworkElement_DefaultTransition}"
                                       local:UIPageTransitionManager.TransitionIndex="0"
                                       Height="456">
                                <Grid DockPanel.Dock="Left" Width="1308">
                                    <Grid Visibility="{Binding HasItems, ElementName=PART_List, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden}}">
                                        <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll1px}"
                                                          CaptureSubgraph="True">
                                            <Grid Background="#ff0A0E1A">
                                                <Grid Style="{StaticResource A_Style_FrameworkElement_HiddenIfSelectedItemTrackMatches}">
                                                    <local:FZMaterial ImageSource="{Binding MediaTrack, Converter={StaticResource A_Converter_TrackToCoverImage}}"
                                                                      Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll1px}"
                                                                      Style="{StaticResource A_Style_FZMaterial_HiddenIfNotLoaded}" />
                                                </Grid>

                                                <local:MapViewControllerWindowed x:Name="RivalsMapMapView"
                                                                                 DataContext="{Binding MainMapData}"
                                                                                 MinMapHeight="1800"
                                                                                 Style="{StaticResource A_Style_MapViewController_UIMap}"
                                                                                 InterpolationTime="0.67"
                                                                                 DesiredMargin="15,15,15,150"/>

                                                <Grid Style="{StaticResource A_Style_FrameworkElement_HiddenIfSelectedItemTrackDoesntMatch}">
                                                    <local:MapCustomRenderElement x:Name="PART_mapCustomRenderElement" 
                                                                                  Style="{StaticResource A_Style_MapCustomRenderElement_UIMap}" 
                                                                                  DataContext="{Binding MainMapData}"
                                                                                  MapView="{Binding ElementName=RivalsMapMapView}" />
                                                </Grid>

                                                <local:FZMaterial x:Name="RouteShadowGradient" Height="190" VerticalAlignment="Bottom" >
                                                    <local:FZMaterial.Preset>
                                                        <local:FZMaterialPresetRoundtangle GradientColorA="#D8000000"
                                                                                           GradientColorB="#00000000" />
                                                    </local:FZMaterial.Preset>
                                                </local:FZMaterial>

                                                <Grid VerticalAlignment="Bottom" HorizontalAlignment="Left">
                                                    <Grid Margin="24,0,24,24">
                                                        <StackPanel Margin="0,0,0,0">
                                                            <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_RivalsRouteName}" 
                                                                               MarkupConverter="{StaticResource A_MappingConverter_Details}"
                                                                               Text="{Binding Name}" />
                                                            <Decorator Height="18"/>
                                                            <AutoScrollPanel Style="{StaticResource H_Style_AutoScrollPanel}"
                                                                            Speed="40"
                                                                            InitialPause="0:0:0.5"
                                                                            ScrollSeparation="50"
                                                                            Orientation="Horizontal"
                                                                            HorizontalAlignment="Left"
                                                                            VerticalAlignment="Bottom"
                                                                            Margin="0,0,24,0">
                                                                <AutoScrollPanel.ContentTemplate>
                                                                    <DataTemplate>
                                                                        <StackPanel Orientation="Horizontal" Margin="0,8">
                                                                            <ItemsControl ItemsPanel="{StaticResource A_Template_RestrictionsPanel}"
                                                                                          ItemsSource="{Binding Restrictions, RelativeSource={RelativeSource AncestorType=Page}}"/>
                                                                            <DockPanel Visibility="{Binding Restrictions, RelativeSource={RelativeSource AncestorType=Page}, FallbackValue=Collapsed, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                                                                                <FZTextBlock Text="{Binding DataContext.Season, RelativeSource={RelativeSource AncestorType=AutoScrollPanel}, Converter={StaticResource A_Converter_Season_To_String_Highlight}}" 
                                                                                            Style="{StaticResource A_Style_FZTextBlock_RivalsRouteDistanceLarge}" />
                                                                                <FZTextBlock DockPanel.Dock="Right" 
                                                                                            Text="/" 
                                                                                            Margin="9,0" 
                                                                                            Style="{StaticResource A_Style_FZTextBlock_RivalsRouteDistanceLarge}" />
                                                                            </DockPanel>
                                                                            <FZTextBlock Text="{local:Loc Rivals.IDS_Distance}"
                                                                                        Style="{StaticResource A_Style_FZTextBlock_RivalsRouteDistanceLarge}"
                                                                                        Margin="0,0,8,0"/>
                                                                            <FZTextBlock Text="{Binding DataContext.MainMapData.Distance, RelativeSource={RelativeSource AncestorType=AutoScrollPanel}, Converter={StaticResource A_StringToUpper}}"
                                                                                        Style="{StaticResource A_Style_FZTextBlock_RivalsRouteDistanceLarge}" 
                                                                                        Color="{StaticResource H_Color_Primary_Green}"/>
                                                                        </StackPanel>
                                                                    </DataTemplate>
                                                                </AutoScrollPanel.ContentTemplate>
                                                            </AutoScrollPanel>
                                                        </StackPanel>

                                                    </Grid>
                                                </Grid>
                                            </Grid>
                                        </local:FZMaterial>
                                    </Grid>
                                </Grid>
                                <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition}"
                                      local:UIPageTransitionManager.TransitionIndex="20003">
                                    <ContentControl Template="{StaticResource A_ControlTemplate_SidePanel}"
                                                    Tag="{local:Loc Main.IDS_Details}"
                                                    Margin="4,0,0,0">
                                        <Grid>
                                            <StackPanel Visibility="{Binding Restrictions, FallbackValue=Hidden, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden}}">
                                            <Grid>
                                                <StackPanel Margin="16,16,16,8"
                                                            Visibility="{Binding RivalInfo, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden}}">
                                                    <local:FZTextBlock Text="{local:Loc Rivals.IDS_RivalName}"
                                                                       Style="{StaticResource A_Style_FZTextBlock_RivalDetailsHeader}"/>
                                                    <Decorator Height="7"/>
                                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_RivalName}" />
                                                    <Decorator Height="16"/>
                                                    <UniformGrid Columns="2">
                                                        <StackPanel>
                                                            <local:FZTextBlock Text="{local:Loc Rivals.IDS_TimeToBeat}"
                                                                               Style="{StaticResource A_Style_FZTextBlock_RivalDetailsHeader}" />
                                                            <Decorator Height="8"/>
                                                            <StackPanel Orientation="Horizontal"
                                                                        Height="24">
                                                                <local:FZTextBlock Text="{Binding RivalInfo.TimeToBeat}"
                                                                                   Style="{StaticResource A_Style_FZTextBlock_RivalDetails}" />
                                                                <Decorator Width="9"/>
                                                                <Decorator Style="{StaticResource A_Style_HideIfNoTargetTime}">
                                                                    <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Anthem/Icons/RivalsLeaderboard/Dirty_Lap.png"
                                                                                      Width="24" Height="24"
                                                                                      Visibility="{Binding RivalInfo.TimeToBeatIsDirty, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden}}" />
                                                                </Decorator>
                                                            </StackPanel>
                                                        </StackPanel>
                                                        <StackPanel>
                                                            <local:FZTextBlock Text="{local:Loc Rivals.IDS_GapToRival}"
                                                                               Style="{StaticResource A_Style_FZTextBlock_RivalDetailsHeader}"
                                                                               HorizontalAlignment="Right" />
                                                            <Decorator Height="8"/>
                                                            <Decorator Height="24">
                                                                <local:FZTextBlock Text="{Binding RivalInfo.TimeDifference}"
                                                                                Style="{StaticResource A_Style_FZTextBlock_RivalDetails}"
                                                                                Color="{StaticResource H_Color_Primary_Green}"
                                                                                HorizontalAlignment="Right" />
                                                            </Decorator>
                                                        </StackPanel>
                                                    </UniformGrid>
                                                </StackPanel>
                                                <ProgressBar Style="{StaticResource A_Style_ProgressBar_WaitSpinner}" 
                                                             HorizontalAlignment="Center" 
                                                             VerticalAlignment="Center"
                                                             Visibility="{Binding RivalInfo, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden_Inverse}}" />
                                            </Grid>
                                            <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_DetailsDivider}" />
                                            <Decorator Margin="16,16,16,0">
                                                <StackPanel Orientation="Vertical"
                                                            Visibility="{Binding RivalInfo, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden}}">
                                                    <local:FZTextBlock Text="{local:Loc Rivals.IDS_VehicleUsed}"
                                                                       Style="{StaticResource A_Style_FZTextBlock_RivalDetailsHeader}" />
                                                    <Decorator Height="7"/>
                                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_RivalDetails}"
                                                                       AutoScroll="{StaticResource A_AutoScrollSettings_CarName}"
                                                                       Text="{Binding RivalInfo.CarName}"/>
                                                    <Decorator Height="7"/>
                                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_RivalDetails}"
                                                                       AutoScroll="{StaticResource A_AutoScrollSettings_CarName}"
                                                                       FontFamily="Horizon_A">
                                                            <local:FZRun Text="{Binding RivalInfo.CarYear}"
                                                                         FontFamily="Horizon_B"/>
                                                            <local:FZRun Text=" " />
                                                            <local:FZRun Text="{Binding RivalInfo.CarManufacturer}"/>
                                                    </local:FZTextBlock>
                                                    <Decorator Height="7"/>
                                                    <StackPanel Orientation="Horizontal"
                                                                Style="{StaticResource A_Style_HideIfNoTargetTime}">
                                                        <Control Style="{StaticResource H_Style_TemplatedElement_CarClassBadge}"
                                                                 local:BindingProxy.A="{Binding RivalInfo.CarPI}"
                                                                 local:BindingProxy.B="{Binding RivalInfo.CarClass}"
                                                                 Height="35" />
                                                        <Decorator Width="7"/>
                                                        <Control Style="{StaticResource A_Style_Control_DriveTrainDisplay}"
                                                                 DataContext="{Binding RivalInfo}"
                                                                 HorizontalAlignment="Right"
                                                                 Height="35"/>
                                                    </StackPanel>
                                                    <Decorator Height="12"/>
                                                    <!-- Car ABS TCS STM  -->
                                                    <Grid Margin="-16,0"
                                                          Style="{StaticResource A_Style_HideIfNoTargetTime}">
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="*" />
                                                            <ColumnDefinition Width="*" />
                                                            <ColumnDefinition Width="*" />
                                                            <ColumnDefinition Width="*" />
                                                        </Grid.ColumnDefinitions>
                                                        <!-- ABS -->
                                                        <StackPanel Orientation="Vertical"
                                                                    Grid.Column="0"
                                                                    HorizontalAlignment="Center">
                                                            <local:FZTextBlock Text="{local:Loc PreRaceMenu.IDS_StartingGrid_ABS}"
                                                                               Style="{StaticResource A_Style_FZTextBlock_RivalDetailsHeader}"
                                                                               HorizontalAlignment="Center"/>
                                                            <ContentControl DataContext="{Binding RivalInfo}"
                                                                            Template="{StaticResource A_ControlTemplate_ABS_White}"/>
                                                        </StackPanel>


                                                                 
                                                        <!-- TCS -->
                                                        <Control Template="{StaticResource A_ControlTemplate_RivalCarProperties_Radio}"
                                                                 Grid.Column="1"
                                                                 local:BindingProxy.A="{local:Loc PreRaceMenu.IDS_StartingGrid_TCS}"
                                                                 local:BindingProxy.B="{Binding RivalInfo.UsedTCS}"/>
                                                        <!-- STM -->
                                                        <Control Template="{StaticResource A_ControlTemplate_RivalCarProperties_Radio}"
                                                                 Grid.Column="2"
                                                                 local:BindingProxy.A="{local:Loc PreRaceMenu.IDS_StartingGrid_STM}"
                                                                 local:BindingProxy.B="{Binding RivalInfo.UsedSTM}"/>
                                                        <!-- GEAR -->
                                                        <StackPanel Orientation="Vertical"
                                                                    Grid.Column="3"
                                                                    HorizontalAlignment="Center">
                                                            <local:FZTextBlock Text="{Convert {local:Loc PreRaceMenu.IDS_StartingGrid_Gear}, Converter={StaticResource A_StringToUpper}}"
                                                                               Style="{StaticResource A_Style_FZTextBlock_RivalDetailsHeader}"
                                                                               HorizontalAlignment="Center"/>
                                                            <local:FZTextBlock Margin="0,9,0,0"
                                                                               DataContext="{Binding RivalInfo}"
                                                                               Style="{StaticResource A_Style_FZTextBlock_Gear}"
                                                                               HorizontalAlignment="Center"
                                                                               CapHeight="18"
                                                                               FontFamily="Horizon_A"
                                                                               Color="{StaticResource A_Color_Body_Text}" />
                                                        </StackPanel>
                                                    </Grid>

                                                </StackPanel>
                                            </Decorator>
                                        </StackPanel>
                                        <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_AutoScroll_Description}" 
                                            Margin="22,24"
                                            Visibility="{Binding Restrictions, FallbackValue=Visible, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden_Inverse}}"/>
                                        </Grid>
                                    </ContentControl>
                                </Grid>
                            </DockPanel>

                            <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition}"
                                  local:UIPageTransitionManager.TransitionIndex="1"
                                  KeyboardNavigation.DirectionalNavigation="Contained"
                                  Margin="0,8,0,0"
                                  Width="1676">
                                <Viewbox>
                                    <local:WrapListBox x:Name="PART_List"
                                                         Style="{StaticResource H_Style_Carousel_Rectangular_7Items}"
                                                         ItemContainerStyle="{StaticResource A_Style_ContentControl_Carousel_ContainerStyle_Rivals}"
                                                         ItemTemplate="{StaticResource A_ControlTemplate_Control_RivalsItemContent}"
                                                         ItemsSource="{Binding Collection}"
                                                         ItemHeight="152"
                                                         Height="160"
                                                         local:FocusOnPageFocusGained.SelectorSelectedItem="True"
                                                         SelectedItem="{Binding SelectedItem, Mode=TwoWay}"/>
                                </Viewbox>
                            </Grid>
                        </StackPanel>
                    </Grid>
                </Grid>
            </Grid>
        </Border>

    </Grid>
</Page>
