<Page DataContext="{Binding RelativeSource={RelativeSource Self}}"
      Style="{StaticResource A_Style_Page_Generic}"
      mc:Ignorable="d"
      x:Class="ForzaUI.A_CarSelect"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
      xmlns:local="clr-namespace:ForzaUI;assembly="
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Page.Resources>
        <ResourceDictionary>
            <local:NumUnitConverter FractionDigits="0"
                                    ShowUnit="False"
                                    x:Key="A_Converter_NumUnit" />
            <SolidColorBrush Color="{StaticResource A_Color_InactiveHeader_Text}"
                             x:Key="A_Brush_LightGray" />

            <Style x:Key="A_Style_FZRun_CarSelect_BOLD" TargetType="{x:Type local:FZRun}">
                <Setter Property="FontFamily" Value="Horizon_A"/>
            </Style>

            <Style x:Key="A_Style_FZMaterial_RarityAndHorizonEditionBonusContainer"
                TargetType="local:FZMaterial">
                <Setter Property="MinHeight" Value="32"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding HorizonEditionBonus, Converter={StaticResource A_StringVisConverter}, FallbackValue=Collapsed}" Value="{x:Static Visibility.Visible}">
                        <Setter Property="MinHeight" Value="47" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_NetworkCountdownControl_CarSelectCustom"
                   TargetType="{x:Type local:NetworkCountdownControl}"
                   BasedOn="{StaticResource A_Style_NetworkCountdownControl_Base}">
                <Setter Property="TimerDisplayName" Value="{local:Loc Lobby.IDS_SelectYourCar_Countdown}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ShowEventSetupCountdown, RelativeSource={RelativeSource AncestorType=Page}}" Value="True">
                        <Setter Property="TimerDisplayName" Value="{local:Loc Lobby.IDS_Event_Options_Countdown}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FrameworkElement_SnowTyres"
                   TargetType="Grid">
                <Setter Property="Visibility" Value="Collapsed" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding HasSnowParts}" Value="1">
                        <DataTrigger.Setters>
                            <Setter Property="Visibility" Value="Visible" />
                        </DataTrigger.Setters>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZMaterial_CarSelect_CostBlock"
                   TargetType="{x:Type local:FZMaterial}"
                   BasedOn="{StaticResource A_Style_FZMaterial_FlatPanel_FooterPanel}">
                <Setter Property="Height" Value="72" />
                <Setter Property="GreedyMeasure" Value="True" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding BlammoType}"
                                 Value="{x:Static local:MarketplaceBlammoType.OnSale}">
                        <Setter Property="Color"
                                Value="{StaticResource A_Color_ItemStatusBackground_Sale}" />
                    </DataTrigger>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding IsPhotoCaptured}"
                                       Value="0" />
                            <Condition Binding="{Binding Visibility, ElementName=PhotoCapturedFooterInfo}"
                                       Value="{x:Static Visibility.Visible}" />
                        </MultiDataTrigger.Conditions>
                        <Setter Property="Color"
                                Value="{StaticResource A_Color_CarCollectionDetailPanelFooterLocked}" />
                    </MultiDataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZMaterial_CarSelect_CurrentLargeIcon"
                   TargetType="{x:Type local:FZMaterial}">
                <Setter Property="Stretch" Value="Uniform" />
                <Setter Property="StretchDirection" Value="DownOnly" />
                <Setter Property="HorizontalAlignment" Value="Center" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="GreedyMeasure" Value="True" />
                <Setter Property="Margin" Value="5" />
            </Style>

            <System:Double x:Key="A_Double_DefaultLargeIconContainerWidth">210</System:Double>
            <local:MappingConverter x:Key="A_Converter_MakeIdToLargeIconContainerWidth"
                                Default="{StaticResource A_Double_DefaultLargeIconContainerWidth}">
                <local:MappingConverterEntry Key="188" Value="300"/> <!-- 188 = LEG - LEGO Speed Champions -->
            </local:MappingConverter>

            <Style x:Key="A_Style_FZMaterial_CarSelect_CurrentLargeIconContainer"
                   TargetType="{x:Type FrameworkElement}">
                <Setter Property="Height" Value="142" />
                <Setter Property="Width" Value="{StaticResource A_Double_DefaultLargeIconContainerWidth}" />
                <Setter Property="Visibility" Value="Collapsed" />
                <Setter Property="Focusable" Value="False" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}}"
                             Value="True">
                        <Setter Property="Visibility"
                                Value="Visible" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZMaterial_CarSelect_CurrentLargeManufacturerIconContainer"
                   TargetType="{x:Type FrameworkElement}"
                   BasedOn="{StaticResource A_Style_FZMaterial_CarSelect_CurrentLargeIconContainer}">
                <Setter Property="Width" Value="{Binding MakeId, Converter={StaticResource A_Converter_MakeIdToLargeIconContainerWidth}, FallbackValue={StaticResource A_Double_DefaultLargeIconContainerWidth}}" />
            </Style>

            <Style x:Key="A_Style_ListBoxItem_CurrentLargeIcon"
                   TargetType="{x:Type ListBoxItem}">
                <Setter Property="Focusable" Value="False" />
            </Style>

            <CornerRadius x:Key="A_CornerRadius_Selection">5</CornerRadius>
            <local:FZMaterialPresetRoundtangle x:Key="A_FZMaterialPresetRoundtangle_Selection"
                                               BasedOn="{StaticResource A_FZMaterialPreset_FlatPanel_Base}"
                                               CornerRadius="{StaticResource A_CornerRadius_Selection}"/>

            <Style x:Key="A_Style_FZMaterial_CarSelect_CurrentLargeIconSelection"
                   TargetType="{x:Type local:FZMaterial}">
                <Setter Property="Preset" Value="{StaticResource A_FZMaterialPresetRoundtangle_Selection}" />
                <Setter Property="Color" Value="#FF3C3C3C" />
                <Setter Property="Width" Value="10" />
                <Setter Property="Height" Value="10" />
                <Setter Property="Margin" Value="5,0,5,0" />
                <Setter Property="Focusable" Value="False" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}}"
                             Value="True">
                        <Setter Property="Color"
                                Value="#FFFF3302" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_ContentControl_CarSelectSidePanelHeader"
                   TargetType="{x:Type ContentControl}">
                <Setter Property="Tag"
                        Value="{local:Loc Tuning.IDS_Performance}" />
                <!-- TODO: Decide if we should show the performance panel when the selection is a fake record
                <Setter Property="Visibility"
                        Value="{Binding IsFakeCarRecord, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}" />
                -->
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsFakeCarRecord}"
                                 Value="True">
                        <Setter Property="Tag"
                                Value="{local:Loc ScreenTitles.IDS_Description}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FrameworkElement_CarouselAligned"
                   TargetType="{x:Type FrameworkElement}">
                <Setter Property="Margin"
                        Value="0,123,0,0" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsBarnFindsScene, FallbackValue=False}"
                                 Value="True">
                        <Setter Property="Margin"
                                Value="0,28,0,0" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FrameworkElement_NoDataContextIfBarnFindUndiscovered"
                   TargetType="FrameworkElement">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding SelectedItem.BarnFindState, ElementName=List, Converter={StaticResource A_Converter_BarnFindStateIsDiscoveredOrLater}}"
                                 Value="{StaticResource A_Boolean_False}">
                        <Setter Property="DataContext"
                                Value="{x:Null}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FrameworkElement_HiddenIfBarnFindUndiscovered"
                   TargetType="FrameworkElement">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding BarnFindState, Converter={StaticResource A_Converter_BarnFindStateIsDiscoveredOrLater}}"
                                 Value="{StaticResource A_Boolean_False}">
                        <Setter Property="Visibility"
                                Value="Hidden" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZMaterial_UnknownManufacturerIcon"
                   BasedOn="{StaticResource A_Style_FZMaterial_CarSelect_CurrentLargeIcon}"
                   TargetType="local:FZMaterial">
                <Setter Property="Visibility"
                        Value="Collapsed" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding BarnFindState, Converter={StaticResource A_Converter_BarnFindStateIsDiscoveredOrLater}}"
                                 Value="{StaticResource A_Boolean_False}">
                       <Setter Property="Visibility"
                                    Value="Visible" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <local:MappingConverter x:Key="A_Converter_BarnFindStateToMessage"
                                    Default="{local:Loc BarnFind.IDS_CarState_Locked}">
                <local:MappingConverterEntry Key="{x:Static local:BarnFindStateEnum.Restored}" Value="{local:Loc BarnFind.IDS_CarState_Ready}" />
                <local:MappingConverterEntry Key="{x:Static local:BarnFindStateEnum.Collected}" Value="{local:Loc BarnFind.IDS_CarState_Restored}" />
                <local:MappingConverterEntry Key="{x:Static local:BarnFindStateEnum.DiscoveredNotAvailable}" Value="{local:Loc BarnFind.IDS_CarState_DiscoveredNotAvailable}" />
            </local:MappingConverter>

            <local:LinearTransformConverter x:Key="A_Int64ToInt32Converter" />

            <local:MultiConverter x:Key="A_Converter_BarnFindStateInt64ToInt32">
                <local:MultiConverterEntry Converter="{StaticResource A_Int64ToInt32Converter}"
                                           TargetType="{x:Type System:Int32}" />
            </local:MultiConverter>

            <local:MultiConverter x:Key="A_Converter_BarnFindStateInt64ToStatusMessage">
                <local:MultiConverterEntry Converter="{StaticResource A_Int64ToInt32Converter}"
                                           TargetType="{x:Type System:Int32}" />
                <local:MultiConverterEntry Converter="{StaticResource A_Converter_BarnFindStateToMessage}" />
            </local:MultiConverter>

            <Style x:Key="A_Style_TextBlock_CarSelect_BarnFindStatus"
                   BasedOn="{StaticResource A_Style_TextBlock_CarSelect_Cost}"
                   TargetType="local:FZTextBlock">
                <Setter Property="Text"
                        Value="{Binding BarnFindState, Converter={StaticResource A_Converter_BarnFindStateInt64ToStatusMessage}}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding BarnFindState, Converter={StaticResource A_Converter_BarnFindStateInt64ToInt32}}"
                                 Value="{x:Static local:BarnFindStateEnum.Discovered}">
                        <Setter Property="Text"
                                Value="{Binding CurrentTask, RelativeSource={RelativeSource AncestorType={x:Type Page}}}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_ContentControl_ScreenTitleBlock_CarSelect"
                   BasedOn="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                   TargetType="ContentControl">
                <Setter Property="local:BindingProxy.A"
                        Value="/ForzaUI;component/Textures/Anthem/Icons/Titles/SteeringWheel.png" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsBarnFindsScene}"
                                 Value="True">
                        <Setter Property="local:BindingProxy.A"
                                Value="/ForzaUI;component/Textures/Anthem/Icons/Titles/BarnFinds.png" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <local:MappingConverter x:Key="A_Converter_CarSelect_RarityToPreset_SelectedItem" Default="{StaticResource A_FZMaterialPreset_FlatPanel_Base}">
                <local:MappingConverterEntry Key="{x:Static local:XAMLRarity.HorizonEdition}" Value="{StaticResource A_FZMaterialPresetRoundtangle_GradientHorizonEdition}" />
            </local:MappingConverter>

            <Style x:Key="A_Style_ControllerButtonControl_CycleBadge"
                TargetType="{x:Type local:ControllerButtonControl}"
                BasedOn="{StaticResource A_Style_ControllerButtonControl_Default}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding SelectedItem.IsFakeCarRecord}" Value="True">
                        <Setter Property="Visibility" Value="{x:Static Visibility.Collapsed}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.BarnFindState, Converter={StaticResource A_Converter_BarnFindStateIsDiscoveredOrLater}}" Value="{StaticResource A_Boolean_False}">
                        <Setter Property="Visibility" Value="{x:Static Visibility.Collapsed}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FrameworkElement_CarSelectSidePanelContainer"
                TargetType="{x:Type FrameworkElement}">
                <Setter Property="local:ManualPassthroughProperty.Allowed" Value="{Binding SelectedItem, ElementName=List, Converter={StaticResource A_Converter_TrueIfNotNull}}"/>
                <Setter Property="local:ScreenReader.Line" Value="{Binding (local:ManualPassthroughProperty.Output), RelativeSource={RelativeSource Self}}"/>
                <Setter Property="local:ScreenReader.LineType" Value="ItemDescription"/>
                <Setter Property="local:ScreenReader.Event" Value="OnChange"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsFakeCarRecord}" Value="{StaticResource A_Boolean_False}">
                        <Setter Property="local:MultiStringFormatter.Format" Value="{local:Loc Main.IDS_ScreenReader_Format_CarSelect_PerformanceInfo}"/>
                        <Setter Property="local:MultiStringFormatter.Param0" Value="{Binding ClassID, Converter={StaticResource A_CarClassToStringConverter}, FallbackValue=?}"/>
                        <Setter Property="local:MultiStringFormatter.Param1" Value="{Binding PerformanceIndex, Converter={StaticResource A_PIConverter}, FallbackValue=?}"/>
                        <Setter Property="local:MultiStringFormatter.Param2" Value="{Binding PowertrainID, Converter={StaticResource A_PowertrainToStringConverter}, FallbackValue=?}"/>
                        <Setter Property="local:MultiStringFormatter.Param3" Value="{Binding Rarity, Converter={StaticResource A_Converter_RarityToNameString}, FallbackValue=?}"/>
                        <Setter Property="local:ManualPassthroughProperty.Input" Value="{Binding (local:MultiStringFormatter.Output), RelativeSource={RelativeSource Self}}"/>
                    </DataTrigger>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding IsFakeCarRecord}" Value="{StaticResource A_Boolean_False}"/>
                            <Condition Binding="{Binding HorizonEditionBonus, Converter={StaticResource A_StringVisConverter}}" Value="{x:Static Visibility.Visible}"/>
                        </MultiDataTrigger.Conditions>
                        <Setter Property="local:MultiStringFormatter.Format" Value="{local:Loc Main.IDS_ScreenReader_Format_CarSelect_PerformanceInfoWithBonus}"/>
                        <Setter Property="local:MultiStringFormatter.Param4" Value="{Binding HorizonEditionBonus, Converter={StaticResource A_Converter_TrimInlineMarkup}, FallbackValue=?}"/>
                    </MultiDataTrigger>
                    <DataTrigger Binding="{Binding IsFakeCarRecord}" Value="{StaticResource A_Boolean_True}">
                        <Setter Property="local:ManualPassthroughProperty.Input" Value="{Binding Text, ElementName=SpecialItemInfoDesc}"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding BarnFindState, Converter={StaticResource A_Converter_BarnFindStateIsDiscoveredOrLater}}"
                                 Value="{StaticResource A_Boolean_False}">
                        <Setter Property="local:ManualPassthroughProperty.Allowed" Value="{StaticResource A_Boolean_False}"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding BarnFindState, Converter={StaticResource A_Converter_BarnFindStateIsDiscoveredNotAvailable}}"
                                 Value="{StaticResource A_Boolean_True}">
                        <Setter Property="local:ManualPassthroughProperty.Allowed" Value="{StaticResource A_Boolean_False}"/>
                     </DataTrigger>
                </Style.Triggers>
            </Style>

            <local:MappingConverter x:Key="A_Converter_VisiblityInverse"
                                    Default="{x:Static Visibility.Collapsed}">
                <local:MappingConverterEntry Key="{x:Static Visibility.Collapsed}"
                                             Value="{x:Static Visibility.Visible}" />
            </local:MappingConverter>

            <Style x:Key="A_Style_FrameworkElement_PhotoCaptureFooterInfo"
                   TargetType="{x:Type FrameworkElement}">
                <Setter Property="Tag"
                        Value="{StaticResource A_Boolean_False}" />
                <Setter Property="Visibility"
                        Value="Collapsed" />
                <Style.Triggers>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding ShowPhotoInfo, RelativeSource={RelativeSource AncestorType=Page}, FallbackValue=False}"
                                       Value="{StaticResource A_Boolean_True}" />
                            <Condition Binding="{Binding Tag, RelativeSource={RelativeSource Self}, FallbackValue=False}"
                                       Value="{StaticResource A_Boolean_True}" />
                        </MultiDataTrigger.Conditions>
                        <Setter Property="Visibility" Value="Visible" />
                    </MultiDataTrigger>
                </Style.Triggers>
            </Style>

        </ResourceDictionary>
    </Page.Resources>
    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}"/>
    </local:UIPageTransitionManager.TransitionManager>
    <Grid x:Name="LayoutRoot">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="RightPanelContentStateGroup">
                <VisualState x:Name="CarStatsPerfBars">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PerformanceStats"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="{x:Static Visibility.Hidden}" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PerformanceBars"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="{x:Static Visibility.Visible}" />
                        </ObjectAnimationUsingKeyFrames>
                        <BooleanAnimationUsingKeyFrames Storyboard.TargetName="PhotoCapturedFooterInfo"
                                                        Storyboard.TargetProperty="Tag">
                            <DiscreteBooleanKeyFrame KeyTime="0"
                                                     Value="{StaticResource A_Boolean_True}" />
                        </BooleanAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="CarStatsPerfStats">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PerformanceBars"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="{x:Static Visibility.Hidden}" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PerformanceStats"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="{x:Static Visibility.Visible}" />
                        </ObjectAnimationUsingKeyFrames>
                        <BooleanAnimationUsingKeyFrames Storyboard.TargetName="PhotoCapturedFooterInfo"
                                                        Storyboard.TargetProperty="Tag">
                            <DiscreteBooleanKeyFrame KeyTime="0"
                                                     Value="{StaticResource A_Boolean_False}" />
                        </BooleanAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup x:Name="SpecialSelectionVisualStateGroup">
                <VisualState x:Name="ViewCarVisualState" />
                <VisualState x:Name="ViewCarSaleVisualState" >
                    <Storyboard>
                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(local:FZMaterial.Color)" Storyboard.TargetName="FooterBox">
                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource A_Color_TileSelected_Background}"/>
                        </ColorAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="BuyCarButtonVisualState">
                    <Storyboard>
                        <StringAnimationUsingKeyFrames Storyboard.TargetName="SpecialItemInfoDesc"
                                                       Storyboard.TargetProperty="(local:FZTextBlock.Text)">
                            <DiscreteStringKeyFrame KeyTime="0"
                                                    Value="{local:Loc CarFlow.IDS_PurchaseCarDesc}" />
                        </StringAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="AllCarsButtonVisualState">
                    <Storyboard>
                        <StringAnimationUsingKeyFrames Storyboard.TargetName="SpecialItemInfoDesc"
                                                       Storyboard.TargetProperty="(local:FZTextBlock.Text)">
                            <DiscreteStringKeyFrame KeyTime="0"
                                                    Value="{local:Loc CarFlow.IDS_AllCars_Desc}" />
                        </StringAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="RentalCarsButtonVisualState">
                    <Storyboard>
                        <StringAnimationUsingKeyFrames Storyboard.TargetName="SpecialItemInfoDesc"
                                                       Storyboard.TargetProperty="(local:FZTextBlock.Text)">
                            <DiscreteStringKeyFrame KeyTime="0"
                                                    Value="{local:Loc CarFlow.IDS_RentalCar_Desc}" />
                        </StringAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="BorrowLeadersCarButtonVisualState">
                    <Storyboard>
                        <StringAnimationUsingKeyFrames Storyboard.TargetName="SpecialItemInfoDesc"
                                                       Storyboard.TargetProperty="(local:FZTextBlock.Text)">
                            <DiscreteStringKeyFrame KeyTime="0"
                                                    Value="{local:Loc CarFlow.IDS_BorrowLeaderCar_Desc}" />
                        </StringAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="LoyaltyRewardVisualState">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="LoyaltyRewardInfo">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup x:Name="BackgroundVisualStateGroup">
                <VisualState x:Name="DefaultBackgroundVisualState" />
                <VisualState x:Name="BlueprintBackgroundVisualState">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DefaultBackground"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="{x:Static Visibility.Collapsed}" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BlueprintBackground"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="{x:Static Visibility.Visible}" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Control x:Name="DefaultBackground"
                 Style="{StaticResource A_Style_Control_ScreenBackground}" />

        <Control  x:Name="BlueprintBackground" Visibility="Collapsed" Template="{StaticResource A_ControlTemplate_Blueprint_Background}"/>

        <local:RoutedEventCommand x:Name="ToggleStatsRoutedEventCommand"
                                  RoutedEvent="UIElement.MouseLeftButtonDown"
                                  Command="{Binding ToggleStatsCommand, RelativeSource={RelativeSource AncestorType=Page}}" />

        <local:RoutedEventCommand x:Name="CycleBadgeRoutedEventCommand"
                                  RoutedEvent="UIElement.MouseLeftButtonDown"
                                  Command="{Binding CycleBadgeCommand, RelativeSource={RelativeSource AncestorType=Page}}" />

        <!-- Bars -->
        <local:PlayerBarControl Style="{StaticResource A_Style_PlayerBarControl_WithTokens}"
                        x:Name="TopBar" />
        <ContentControl Style="{StaticResource A_Style_ButtonBar}"
                        x:Name="BottomBar">
            <local:ControllerButtonPanel x:Name="HelpPanel"
                                         Style="{StaticResource A_Style_ControllerButtonPanel_Default}">
                <local:ControllerButtonControl Button="A"
                                               Description="{local:Loc HelpButtons.IDS_Select}" />
                <local:ControllerButtonControl Button="B"
                                               Description="{local:Loc HelpButtons.IDS_Back}" />
                <local:ControllerButtonControl Button="X"
                                               Description="{local:Loc HelpButtons.IDS_Sort}"
                                               Visibility="{Binding IsBarnFindsScene, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}" />
                <local:ControllerButtonControl Button="Y"
                                               Description="{local:Loc HelpButtons.IDS_CarFilter}"
                                               Visibility="{Binding IsBarnFindsScene, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}" />
                <local:ControllerButtonControl Button="RThumb_Up"
                                               InputOverride="{local:Input Command=INPUTCMD_UI_RIGHT_STICK_UP, Context=INPUTCONTEXT_UI}"
                                               Description="{local:Loc HelpButtons.IDS_ToggleStats}"
                                               Visibility="{Binding SelectedItem.IsFakeCarRecord, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}"
                                               local:RoutedEventCommand.Action="{Binding ElementName=ToggleStatsRoutedEventCommand}" />
                <local:ControllerButtonControl Style="{StaticResource A_Style_ControllerButtonControl_CycleBadge}"
                                               Button="RThumb_Right"
                                               InputOverride="{local:Input Command=INPUTCMD_UI_RIGHT_STICK_RIGHT, Context=INPUTCONTEXT_UI}"
                                               Description="{local:Loc HelpButtons.IDS_CycleBadge}"
                                               local:RoutedEventCommand.Action="{Binding ElementName=CycleBadgeRoutedEventCommand}" />
            </local:ControllerButtonPanel>
        </ContentControl>

        <local:NetworkCountdownControl Style="{StaticResource A_Style_NetworkCountdownControl_CarSelectCustom}"
                                       AudioEnabled="True"
                                       WarningSeconds="0" />

        <Border Style="{StaticResource A_Style_Border_ScenePadding_Opus}" x:Name="Frame">
            <Grid Style="{StaticResource A_Style_FrameworkElement_ScreenTilt}">
                <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                    <StackPanel>
                        <Decorator Margin="15,0,0,0"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Top">
                            <ContentControl Content="{Binding Title}"
                                            Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock_CarSelect}"
                                            x:Name="TitleBlock" />
                        </Decorator>
                        <local:ItemsSelector x:Name="ManufacturerItemsSelector"
                                             HorizontalAlignment="Center"
                                             WrapSelection="True"
                                             ItemsSource="{Binding Groups}"
                                             SelectedIndex="{Binding CurrentGroupIndex}"
                                             Style="{StaticResource A_Style_Carousel6ItemList_TabBar}"
                                             ItemContainerStyle="{StaticResource A_Style_ContentControl_CarSelect_TabBarItem}"
                                             Visibility="{Binding IsBarnFindsScene, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}"/>

                        <Grid Margin="15,0,0,0">
                            <local:CommonListBox ItemTemplate="{StaticResource A_DataTemplate_CarSelectCarouselItem}"
                                                     Style="{StaticResource A_Style_CommonListBox_FullScreenCarousel}"
                                                     SelectedItem="{Binding SelectedItem}"
                                                     ItemsSource="{Binding Collection}"
                                                     local:CollectionIndexer.Collection="{Binding Collection}"
                                                     x:Name="List"
                                                     local:FocusOnPageFocusGained.SelectorSelectedItem="True" />
                            <Grid DataContext="{Binding SelectedItem, ElementName=List}"
                                  HorizontalAlignment="Left"
                                  VerticalAlignment="Center"
                                  Style="{StaticResource A_Style_FrameworkElement_CarSelectSidePanelContainer}">
                                <DockPanel LastChildFill="True"
                                               Width="342"
                                               Height="699">
                                    <local:FZMaterialGlassCapture />
                                    <ContentControl DockPanel.Dock="Left"
                                                        Style="{StaticResource A_Style_ContentControl_CarSelectSidePanelHeader}"
                                                        Template="{StaticResource A_ControlTemplate_SidePanelWithMouseRollover}"
                                                        x:Name="PerformancePanel"
                                                        local:RoutedEventCommand.Action="{Binding ElementName=ToggleStatsRoutedEventCommand}">
                                        <Grid>
                                            <DockPanel x:Name="PerformanceInfo"
                                                           Visibility="{Binding IsFakeCarRecord, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}">
                                                <Grid HorizontalAlignment="Center"
                                                               DockPanel.Dock="Top"
                                                               Margin="0,20,0,0">
                                                    <local:CommonListBox x:Name="CurrentCarLargeIconBox"
                                                                             PageSize="1"
                                                                             Focusable="False"
                                                                             SelectedIndex="0"
                                                                             ItemContainerStyle="{StaticResource A_Style_ListBoxItem_CurrentLargeIcon}"
                                                                             Style="{StaticResource A_Style_FrameworkElement_HiddenIfBarnFindUndiscovered}">
                                                        <Decorator Style="{StaticResource A_Style_FZMaterial_CarSelect_CurrentLargeManufacturerIconContainer}">
                                                            <local:FZMaterial ImageSource="{Binding ManufacturerIcon}"
                                                                                  Style="{StaticResource A_Style_FZMaterial_CarSelect_CurrentLargeIcon}" />
                                                        </Decorator>
                                                        <Decorator Style="{StaticResource A_Style_FZMaterial_CarSelect_CurrentLargeIconContainer}">
                                                            <local:FZMaterial ImageSource="{Binding CarBucketIcon}"
                                                                                  Style="{StaticResource A_Style_FZMaterial_CarSelect_CurrentLargeIcon}" />
                                                        </Decorator>
                                                    </local:CommonListBox>
                                                    <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/UI_Symbols/BarnFind_UnknownManufacturer.png"
                                                                          Style="{StaticResource A_Style_FZMaterial_UnknownManufacturerIcon}"
                                                                          Color="#81FFFFFF"
                                                                          Margin="5,1,5,1"
                                                                          GreedyMeasure="False"
                                                                          Height="140"
                                                                          Width="140" />
                                                </Grid>
                                                <Decorator DockPanel.Dock="Top"
                                                               Margin="0,16,0,16"
                                                               Style="{StaticResource A_Style_FrameworkElement_HiddenIfBarnFindUndiscovered}">
                                                    <local:CommonListBox x:Name="CurrentSelectionInCarLargeIconBox"
                                                                             SelectedIndex="{Binding SelectedIndex, ElementName=CurrentCarLargeIconBox}"
                                                                             HorizontalAlignment="Center"
                                                                             PageSize="1"
                                                                             Focusable="False">
                                                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CarSelect_CurrentLargeIconSelection}" />
                                                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CarSelect_CurrentLargeIconSelection}" />
                                                    </local:CommonListBox>
                                                </Decorator>
                                                <Decorator Height="32"
                                                    Width="342"
                                                    DockPanel.Dock="Top">
                                                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_RarityAndHorizonEditionBonusContainer}"
                                                                      VerticalAlignment="Center"
                                                                      Preset="{Binding Rarity, Converter={StaticResource A_Converter_CarSelect_RarityToPreset_SelectedItem}}"
                                                                      Color="{Binding Rarity, Converter={StaticResource A_Converter_RarityToColor}}">
                                                        <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                                            <local:FZTextBlock Height="13" Text="{Binding Rarity, Converter={StaticResource A_Converter_RarityToNameString}}" HorizontalAlignment="Center" VerticalAlignment="Center" CapHeight="13" Color="#FFFFFFFF"/>
                                                            <local:FZTextBlock Height="13" Margin="0,5,0,0" local:TextBlockInlineMarkup.Markup="{Binding HorizonEditionBonus, Converter={StaticResource A_StringToUpper}}" local:TextBlockInlineMarkup.ResourceBaseName="A_Style_FZRun_CarSelect_" HorizontalAlignment="Center" VerticalAlignment="Center" CapHeight="13" Color="#FFFFFFFF" Visibility="{Binding HorizonEditionBonus, Converter={StaticResource A_StringVisConverter}}" FontFamily="Horizon_B"/>
                                                        </StackPanel>
                                                    </local:FZMaterial>
                                                </Decorator>
                                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CarSelect_CostBlock}"
                                                              x:Name="FooterBox"
                                                              DockPanel.Dock="Bottom">
                                                    <Grid Visibility="{Binding ShowCost, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                                                        <Grid Visibility="{Binding IsBarnFindsScene, FallbackValue=Visible, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}">
                                                            <Grid HorizontalAlignment="Center"
                                                                  VerticalAlignment="Bottom"
                                                                  Visibility="{Binding Visibility, ElementName=PhotoCapturedFooterInfo, Converter={StaticResource A_Converter_VisiblityInverse}}">
                                                                <StackPanel Orientation="Horizontal"
                                                                            Visibility="{Binding CannotBeObtained, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}, FallbackValue=Visible}">
                                                                    <DockPanel x:Name="CreditsCostBlock">
                                                                        <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/Anthem/CarSelect/Credit_CarSelect.png"
                                                                                              Width="80"
                                                                                              Height="68"
                                                                                              Stretch="Uniform"
                                                                                              DockPanel.Dock="Left"
                                                                                              Margin="0,0,-32,0" />
                                                                        <Viewbox StretchDirection="DownOnly">
                                                                            <local:FZTextBlock Style="{StaticResource A_Style_TextBlock_CarSelect_CostOrFree}"
                                                                                                   Tag="{Binding CarCreditCost, ConverterParameter=money, Converter={StaticResource A_Converter_NumUnit}, FallbackValue=0}"
                                                                                                   HorizontalAlignment="Left" />
                                                                        </Viewbox>
                                                                    </DockPanel>
                                                                    <DockPanel x:Name="TokensCostBlock"
                                                                                   Margin="25,0,0,0"
                                                                                   Visibility="{Binding AreTokensEnabled, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                                                                        <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/Anthem/CarSelect/Token_CarSelect.png"
                                                                                              Width="80"
                                                                                              Height="68"
                                                                                              Stretch="Uniform"
                                                                                              DockPanel.Dock="Left"
                                                                                              Margin="0,0,-32,0" />
                                                                        <Viewbox StretchDirection="DownOnly">
                                                                            <local:FZTextBlock Style="{StaticResource A_Style_TextBlock_CarSelect_CostOrFree}"
                                                                                                   Tag="{Binding CarTokenCost, ConverterParameter=tokenmoney, Converter={StaticResource A_Converter_NumUnit}, FallbackValue=0}"
                                                                                                   HorizontalAlignment="Left" />
                                                                        </Viewbox>
                                                                    </DockPanel>
                                                                </StackPanel>
                                                                <Viewbox StretchDirection="DownOnly"
                                                                         Height="68"
                                                                         Visibility="{Binding CannotBeObtained, Converter={StaticResource A_FZBooleanToVisibilityConverter}, FallbackValue=Collapsed}">
                                                                    <local:FZTextBlock Style="{StaticResource A_Style_TextBlock_CarSelect_CostOrFree}"
                                                                                       Text="{Binding Source={local:Loc CarFlow.IDS_CarCollection_CannotBeObtained}, Converter={StaticResource A_StringToUpper}}"
                                                                                       HorizontalAlignment="Left"
                                                                                       VerticalAlignment="Top" />
                                                                </Viewbox>
                                                            </Grid>
                                                            <StackPanel Style="{StaticResource A_Style_FrameworkElement_PhotoCaptureFooterInfo}"
                                                                        Orientation="Horizontal"
                                                                        HorizontalAlignment="Center"
                                                                        VerticalAlignment="Bottom"
                                                                        x:Name="PhotoCapturedFooterInfo">
                                                                <DockPanel x:Name="PromoPhotoCapturedBlock">
                                                                    <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/Promo/Car_Collection/CarSelectDescription_CameraIcon.png"
                                                                                      Width="85"
                                                                                      Height="68"
                                                                                      Stretch="Uniform"
                                                                                      DockPanel.Dock="Left"
                                                                                      Margin="0,0,-32,0" />
                                                                    <Viewbox StretchDirection="DownOnly">
                                                                        <local:FZTextBlock Style="{StaticResource A_Style_TextBlock_CarSelect_CapturedNotCaptured}"
                                                                                           HorizontalAlignment="Left" />
                                                                    </Viewbox>
                                                                </DockPanel>
                                                            </StackPanel>
                                                        </Grid>
                                                        <Decorator Visibility="{Binding IsBarnFindsScene, FallbackValue=Collapsed, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                                                       Margin="8">
                                                            <local:FZTextBlock Style="{StaticResource A_Style_TextBlock_CarSelect_BarnFindStatus}"
                                                                                   HorizontalAlignment="Center" />
                                                        </Decorator>
                                                    </Grid>
                                                </local:FZMaterial>
                                                <Grid Margin="24"
                                                      DockPanel.Dock="Bottom"
                                                      Style="{StaticResource A_Style_FrameworkElement_NoDataContextIfBarnFindUndiscovered}">
                                                    <Grid HorizontalAlignment="Left">
                                                        <Control Style="{StaticResource A_Style_Control_CarClassBadge_Small}"
                                                                 local:BindingProxy.A="{Binding PerformanceIndex}"
                                                                 local:BindingProxy.B="{Binding ClassID}"
                                                                 Visibility="{Binding EliminatorLevel, Converter={StaticResource A_Converter_HiddenIfValid}, FallbackValue={x:Static Visibility.Visible}}" />
                                                        <Control Template="{StaticResource A_ControlTemplate_EliminatorCarLevel_Small}"
                                                                 Visibility="{Binding EliminatorLevel, Converter={StaticResource A_Converter_VisibleIfValid}, FallbackValue={x:Static Visibility.Collapsed}}" />
                                                    </Grid>
                                                    <Control Style="{StaticResource A_Style_Control_DriveTrainDisplay}"
                                                                 HorizontalAlignment="Right" />
                                                </Grid>
                                                <Grid Margin="24"
                                                          Style="{StaticResource A_Style_FrameworkElement_NoDataContextIfBarnFindUndiscovered}">
                                                    <Grid x:Name="PerformanceBars">
                                                        <StackPanel Orientation="Vertical">
                                                            <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Speed}"
                                                                                        BaseValue="{Binding SpeedRating}"
                                                                                        NewValue="{Binding SpeedRating}" />
                                                            <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Handling}"
                                                                                        BaseValue="{Binding HandlingRating}"
                                                                                        NewValue="{Binding HandlingRating}" />
                                                            <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Acceleration}"
                                                                                        BaseValue="{Binding AccelerationRating}"
                                                                                        NewValue="{Binding AccelerationRating}" />
                                                            <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Launch}"
                                                                                        BaseValue="{Binding LaunchRating}"
                                                                                        NewValue="{Binding LaunchRating}" />
                                                            <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Braking}"
                                                                                        BaseValue="{Binding BrakingRating}"
                                                                                        NewValue="{Binding BrakingRating}" />
                                                        </StackPanel>
                                                    </Grid>
                                                    <Grid Visibility="Hidden"
                                                              x:Name="PerformanceStats">
                                                        <Control Style="{StaticResource A_Style_Control_CarPerfStats}"
                                                                     Tag="{Binding}" />
                                                    </Grid>
                                                </Grid>
                                            </DockPanel>
                                            <DockPanel Visibility="{Binding IsFakeCarRecord, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CarSelect_CostBlock}"
                                                                      DockPanel.Dock="Bottom"/>
                                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_Body}"
                                                                       Color="{StaticResource A_Color_Body_Text}"
                                                                       Margin="24" TextWrapping="Wrap"
                                                                       x:Name="SpecialItemInfoDesc"
                                                                       FontSize="22" />
                                            </DockPanel>
                                        </Grid>
                                    </ContentControl>
                                </DockPanel>
                            </Grid>

                            <local:NavigationArrows Style="{StaticResource A_Style_Control_NavigationArrows}"
                                                    Margin="-40,0,-20,0"
                                                    CanSelectPrev="{Binding CanSelectPrev, ElementName=List}"
                                                    CanSelectNext="{Binding CanSelectNext, ElementName=List}"
                                                    ScrollPagePrevCommand="{Binding ScrollPagePrevCommand, ElementName=List}"
                                                    ScrollPageNextCommand="{Binding ScrollPageNextCommand, ElementName=List}" />
                        </Grid>
                    </StackPanel>
                </Grid>
            </Grid>
        </Border>
        <!--<StackPanel>
        <local:FZTextBlock Text="Purchasable" 
                           Visibility="{Binding SelectedItem.PurchasableCar, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
        <local:FZTextBlock Text="Wheelspin" 
                           Visibility="{Binding SelectedItem.WheelspinPrizeCar, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
        <local:FZTextBlock Text="IsBarnFind" 
                           Visibility="{Binding SelectedItem.IsBarnFind, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
        <local:FZTextBlock Text="PerkCar" 
                           Visibility="{Binding SelectedItem.PerkCar, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
        <local:FZTextBlock Text="ThreadRewardCar" 
                           Visibility="{Binding SelectedItem.ThreadRewardCar, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
        <local:FZTextBlock Text="HouseRewardCar" 
                           Visibility="{Binding SelectedItem.HouseRewardCar, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>

        </StackPanel>-->
    </Grid>
</Page>
