<Page xmlns:local="clr-namespace:ForzaUI;assembly="
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      x:Class="ForzaUI.A_SIDIPurchaseCar"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <Page.Resources>
        <ResourceDictionary>
            
            <Style x:Key="A_Style_Border_ScenePadding_SIDIPurchaseCar"
                   TargetType="Border"
                   BasedOn="{StaticResource A_Style_Border_ScenePadding_Opus}">
                <Setter Property="Padding" Value="71,143,71,152"/>
            </Style>

            <Style x:Key="A_Style_FZMaterial_PurchaseOption_SubIcon"
                TargetType="local:FZMaterial">
                <Setter Property="Visibility" Value="Collapsed" />
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_Black}" />
                <Style.Triggers>
                    <DataTrigger
                        Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}}"
                        Value="True">
                        <Setter
                            Property="Color"
                            Value="{StaticResource H_Color_Primary_White}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding IsEnabled}" Value="False">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/Icons/Pad_Lock.png"/>
                        <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="H_Style_Control_Markup_CreditsIcon" TargetType="Control"
                BasedOn="{StaticResource H_Style_Control_CreditsIcon}">
                <Setter Property="Height" Value="30"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="Margin" Value="2,0"/>
            </Style>

            <MappingConverter x:Key="H_Markup_Credits_Icon">
                <MappingConverterEntry Key="{NoCase CREDITS}" Value="{StaticResource H_Style_Control_Markup_CreditsIcon}"/>
            </MappingConverter>

            <DataTemplate x:Key="A_DataTemplate_TextMenu_PurchaseDetails">
                <DataTemplate.Resources>
                    <Style x:Key="A_Style_FZTextBlock_OptionText_ViewPurchaseOption" TargetType="local:FZTextBlock"
                           BasedOn="{StaticResource A_Style_FZTextBlock_OptionText}">
                        <Setter Property="FontFamily" Value="Horizon_B" />
                        <Setter Property="HorizontalAlignment" Value="Left" />
                        <Setter Property="VerticalAlignment" Value="Center" />
                        <Setter Property="MarkupConverter" Value="{StaticResource H_Markup_Credits_Icon}" />
                    </Style>
                </DataTemplate.Resources>
                <Grid IsHitTestVisible="False"
                      Margin="24,0"
                      Height="50">
                    <DockPanel LastChildFill="True">
                        <FZTextBlock x:Name="MainText"
                                     DockPanel.Dock="Left"
                                     Text="{Binding Text}"
                                     Style="{StaticResource A_Style_FZTextBlock_OptionText_ViewPurchaseOption}"
                                     CapHeight="18"
                                     Margin="0,0,0,0"
                                     HorizontalAlignment="Left"/>
                        <FZMaterial x:Name="SubIcon"
                                    DockPanel.Dock="Right"
                                    Width="22"
                                    Height="25"
                                    VerticalAlignment="Center"
                                    Margin="5,0,0,0"
                                    Style="{StaticResource A_Style_FZMaterial_PurchaseOption_SubIcon}"
                                    HorizontalAlignment="Right"/>
                        <FZTextBlock x:Name="OptionText"
                                     DockPanel.Dock="Right"
                                     Text="{Binding Subtext}"
                                     Style="{StaticResource A_Style_FZTextBlock_OptionText_ViewPurchaseOption}"
                                     HorizontalAlignment="Right"
                                     FontFamily="Horizon_A"
                                     CapHeight="18"
                                     Margin="11,0,0,0"
                                     VerticalAlignment="Center"/>
                    </DockPanel>
                </Grid>
                <DataTemplate.Triggers>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding IsEnabled}" Value="False"/>
                        </MultiDataTrigger.Conditions>
                        <Setter TargetName="MainText" Property="Color" Value="{StaticResource H_Color_Primary_Grey_80pc}"/>
                        <Setter TargetName="OptionText" Property="Color" Value="{StaticResource H_Color_Secondary_Negative}"/>
                        <Setter TargetName="SubIcon" Property="Color" Value="{StaticResource H_Color_Primary_Grey_80pc}"/>
                    </MultiDataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <Style
                BasedOn="{StaticResource A_Style_ListBoxItem_TextMenu_Gaps}"
                TargetType="{Type ListBoxItem}"
                x:Key="A_Style_ListBoxItem_TextMenu_PurchaseOption">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsEnabled}" Value="False">
                        <Setter Property="Tag" Value="Inactive"/>
                        <Setter Property="Focusable" Value="False"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_Upgrade_Tiles" TargetType="FZTextBlock">
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_White}"/>
                <Setter Property="FontFamily" Value="Horizon_A"/>
                <Setter Property="CapHeight" Value="18"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="AutoScroll" Value="{StaticResource H_AutoScrollSettings_Horizontal_Title}"/>
                <Setter Property="AutoScroll.AllowScrolling" Value="True"/>
            </Style>

            <Style x:Key="H_Style_FZTextBlock_Status" TargetType="FZTextBlock">
                <Setter Property="TextAlignment" Value="Right"/>
                <Setter Property="CapHeight" Value="18"/>
                <Setter Property="FontFamily" Value="Horizon_A"/>
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_White}"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="Stretch" Value="None"/>
                <Setter Property="Visibility" Value="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource A_StringVisConverter}}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Text, RelativeSource={RelativeSource Self}}" Value="10.0">
                        <Setter Property="Color" Value="{StaticResource H_Color_Secondary_Positive}"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <ControlTemplate x:Key="A_Template_Control_Upgrades_Bars" TargetType="Control">
                <ControlTemplate.Resources>
                    <MappingConverter x:Key="A_Converter_InfoView_to_StatValueB_Width" Default="30">
                        <MappingConverterEntry Key="{x:Static SIDIInfoViewState.PerformanceStats}" Value="100"/>
                    </MappingConverter>
                </ControlTemplate.Resources>
                <StackPanel Orientation="Vertical">
                    <Decorator Height="40"
                               VerticalAlignment="Center"
                               HorizontalAlignment="Stretch">
                        <DockPanel>
                            <FZTextBlock x:Name="Title"
                                         Text="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}"
                                         Style="{StaticResource A_Style_FZTextBlock_Upgrade_Tiles}"
                                         Width="150"/>
                            <Grid DockPanel.Dock="Right">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <FZTextBlock x:Name="StatValueA"
                                            Style="{StaticResource H_Style_FZTextBlock_Status}"
                                            Grid.Column="0"
                                            HorizontalAlignment="Right"
                                            Text="{Binding Path=(BindingProxy.A), RelativeSource={RelativeSource TemplatedParent}}"/>
                                <StackPanel Orientation="Horizontal"
                                            Grid.Column="1"
                                            HorizontalAlignment="Right">
                                    <ContentControl Style="{StaticResource H_Style_TemplatedWrapper_PerformanceChangeBox}"
                                                    Content="{Binding Path=(BindingProxy.C), RelativeSource={RelativeSource TemplatedParent}}"
                                                    Width="24"
                                                    Height="24"/>
                                    <Decorator Width="12"/>
                                    <FZTextBlock x:Name="StatValueB"
                                                Style="{StaticResource H_Style_FZTextBlock_Status}"
                                                Text="{Binding Path=(BindingProxy.B), RelativeSource={RelativeSource TemplatedParent}}"
                                                Width="{Binding InfoView, Converter={StaticResource A_Converter_InfoView_to_StatValueB_Width}, RelativeSource={RelativeSource AncestorType=Page}}"/>
                                </StackPanel>
                            </Grid>
                        </DockPanel>
                    </Decorator>
                    <local:FZMaterial Height="2"
                                      Opacity="0.2"/>
                </StackPanel>
            </ControlTemplate>

            <ControlTemplate x:Key="A_Template_Control_Column_Titles" TargetType="Control">
                <StackPanel Orientation="Vertical">
                    <Decorator Height="40"
                               VerticalAlignment="Center"
                               HorizontalAlignment="Stretch">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <FZTextBlock x:Name="Title"
                                         Style="{StaticResource A_Style_FZTextBlock_Upgrade_Tiles}"
                                         Text="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}"
                                         Grid.Column="0"/>
                            <FZTextBlock x:Name="StockValue"
                                         Style="{StaticResource A_Style_FZTextBlock_Upgrade_Tiles}"
                                         Text="{Binding Path=(BindingProxy.A), RelativeSource={RelativeSource TemplatedParent}}"
                                         HorizontalAlignment="Right"
                                         Grid.Column="1"/>
                            <FZTextBlock x:Name="MotifiedValue"
                                         Style="{StaticResource A_Style_FZTextBlock_Upgrade_Tiles}"
                                         Text="{Binding Path=(BindingProxy.B), RelativeSource={RelativeSource TemplatedParent}}"
                                         HorizontalAlignment="Right"
                                         Grid.Column="2"/>
                        </Grid>
                    </Decorator>
                    <local:FZMaterial Height="2"
                                      Opacity="0.2"/>
                </StackPanel>
            </ControlTemplate>

            <Style x:Key="A_Style_Control_SelectionDots_StatsSelection" TargetType="Control">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <FZMaterial x:Name="InnerFilling"
                                        Style="{StaticResource A_Style_Tile_SelectionDots_Base}">
                                <FZMaterial x:Name="OutlineStroke" 
                                            Style="{StaticResource A_Style_Tile_SelectionDots_Base_Outline}"/>
                            </FZMaterial>
                            <ControlTemplate.Triggers>
                                <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}}"
                                        Value="True">
                                    <Setter Property="Style" TargetName="OutlineStroke" Value="{StaticResource A_Style_Tile_SelectionDots_Selected_Base_Outline}"/>
                                    <Setter Property="Style" TargetName="InnerFilling" Value="{StaticResource A_Style_Tile_SelectionDots_Selected_Base}"/>
                                </DataTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="Width" Value="18" />
                <Setter Property="Height" Value="18" />
                <Setter Property="Margin" Value="4,0" />
                <Setter Property="Focusable" Value="False" />
            </Style>

            <Style x:Key="A_Style_Control_SelectionDots" TargetType="Control">
                <Setter Property="Margin" Value="0,12"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Control">
                            <ControlTemplate.Resources>
                                <MappingConverter x:Key="A_Converter_SIDIInfoViewState_to_SelectedIndex" Default="0" CheckEnumKey="SIDIInfoViewState">
                                    <MappingConverterEntry Key="{x:Static SIDIInfoViewState.Combined}" Value="0"/>
                                    <MappingConverterEntry Key="{x:Static SIDIInfoViewState.Stats}" Value="0"/>
                                    <MappingConverterEntry Key="{x:Static SIDIInfoViewState.PerformanceStats}" Value="1"/>
                                    <MappingConverterEntry Key="{x:Static SIDIInfoViewState.Description}" Value="2"/>
                                </MappingConverter>
                            </ControlTemplate.Resources>
                            <CommonListBox SelectedIndex="{Binding InfoView, Converter={StaticResource A_Converter_SIDIInfoViewState_to_SelectedIndex}, RelativeSource={RelativeSource AncestorType=Page}}"
                                            HorizontalAlignment="Center"
                                            PageSize="1"
                                            Focusable="False"
                                            Margin="0,0,0,0">
                                <Control Style="{StaticResource A_Style_Control_SelectionDots_StatsSelection}" />
                                <Control Style="{StaticResource A_Style_Control_SelectionDots_StatsSelection}" />
                                <Control Style="{StaticResource A_Style_Control_SelectionDots_StatsSelection}" />
                            </CommonListBox>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding InfoView, RelativeSource={RelativeSource AncestorType=Page}}" Value="{x:Static SIDIInfoViewState.Combined}">
                        <Setter Property="Visibility" Value="Collapsed"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <AutoScrollSettings x:Key="A_AutoScrollSettings_CarDescription"
                                ScrollOrientation="Vertical"
                                ScrollSeparation="50"
                                Speed="20"/>

            <ControlTemplate x:Key="A_Template_Control_TreasureCar_Collected" TargetType="Control">
                <Grid>
                </Grid>
            </ControlTemplate>

            <ControlTemplate x:Key="A_Template_Control_AfterMarket_CarPurchase" TargetType="Control">
                <ControlTemplate.Resources>
                    <FZMaterialPresetRoundtangleStroke x:Key="A_FZMaterialPresetRoundtangleStroke_OwnedTag"
                                                       CornerRadius="{StaticResource H_CornerRadius_All_2px}"
                                                       Thickness="2" />
                </ControlTemplate.Resources>
                <StackPanel>
                    <FZMaterial Height="2"
                                Opacity="0.2"/>
                    <DockPanel Height="50">
                        <FZMaterial x:Name="RetailPriceSign"
                                    ImageSourceNoPreload="game:/Media/UI/Textures/Data_Bound/SeeItDriveIt/Aftermarket/Sale_Sticker.png"
                                    Height="30"
                                    MaxWidth="130"
                                    VerticalAlignment="Center"
                                    DockPanel.Dock="Left">
                            <FZMaterial.UVMap>
                                <FZMaterialUVMap StretchRegion="3,0,12,0"
                                                UnstretchedSize="19,30" />
                            </FZMaterial.UVMap>
                            <FZTextBlock CapHeight="16"
                                         Color="{StaticResource H_Color_Primary_Black}"
                                         Text="{Binding DiscountPercentage}"
                                         Margin="7,0,18,0"
                                         VerticalAlignment="Center"
                                         FontFamily="Horizon_A"/>
                        </FZMaterial>
           
                        <Grid DockPanel.Dock="Right">
                            
                            <DockPanel HorizontalAlignment="Right">
                                <FZMaterial x:Name="OwnedTag"
                                            Preset="{StaticResource A_FZMaterialPresetRoundtangleStroke_OwnedTag}"
                                            Color="{StaticResource H_Color_Grey}"
                                            Margin="10,0"
                                            Height="30"
                                            Visibility="{Binding IsCarOwned, Converter={StaticResource A_Converter_BoolToVis}}">
                                    <FZTextBlock Text="{Loc SeeItDriveIt.IDS_Aftermarket_Owned}"
                                                CapHeight="18"
                                                Color="{StaticResource H_Color_Primary_White}"
                                                VerticalAlignment="Center"
                                                Margin="12,6"/>
                                </FZMaterial>
                                <Grid DockPanel.Dock="Right">
                                    <local:FZTextBlock x:Name="RetailPriceText"
                                                        Text="{Binding RetailPrice}"
                                                        VerticalAlignment="Center"
                                                        Color="{StaticResource H_Color_Primary_White}"
                                                        CapHeight="18"
                                                        Margin="0"
                                                        MarkupConverter="{StaticResource H_Markup_Credits_Icon}"/>

                                    <local:FZMaterial x:Name="RetailPriceStrikeThrough"
                                                        Color="{StaticResource H_Color_Primary_Black}"
                                                        Height="2"
                                                        Width="{Binding ActualWidth, ElementName=RetailPriceText, Converter={LinearTransformConverter Add=-30}}"
                                                        VerticalAlignment="Center"
                                                        Margin="0,0,-40,0"/>
                                </Grid>
                            </DockPanel>
                        </Grid>
                    </DockPanel>
                </StackPanel>
            </ControlTemplate>

            <ControlTemplate x:Key="A_Template_Control_Upsell_FestivalPlaylist" TargetType="Control">
                <ControlTemplate.Resources>
                    <MappingConverter x:Key="A_Converter_PlaylistCollectionState_to_Visibility" Default="{x:Static Visibility.Hidden}">
                        <MappingConverterEntry Key="{x:Static FestivalPlaylistProgressState.InProgress}" Value="{x:Static Visibility.Hidden}"/>
                        <MappingConverterEntry Key="{x:Static FestivalPlaylistProgressState.Uncollected}" Value="{x:Static Visibility.Visible}"/>
                        <MappingConverterEntry Key="{x:Static FestivalPlaylistProgressState.Collected}" Value="{x:Static Visibility.Visible}"/>
                    </MappingConverter>

                    <MappingConverter x:Key="A_Converter_PlaylistCollectionState_to_StateText">
                        <MappingConverterEntry Key="{x:Static FestivalPlaylistProgressState.InProgress}" Value="{Loc SeeItDriveIt.IDS_Upsell_PlaylistReward}"/>
                        <MappingConverterEntry Key="{x:Static FestivalPlaylistProgressState.Uncollected}" Value="{Loc SeeItDriveIt.IDS_Upsell_ReadyToRedeem}"/>
                        <MappingConverterEntry Key="{x:Static FestivalPlaylistProgressState.Collected}" Value="{Loc SeeItDriveIt.IDS_Upsell_Collected}"/>
                    </MappingConverter>
                </ControlTemplate.Resources>
                <StackPanel>
                    <FZMaterial Height="2"
                                Opacity="0.2"/>
                    <DockPanel Height="50">
                        <FZMaterial x:Name="CheckBox"
                                Style="{StaticResource A_Style_FZMaterial_FestivalPass_CheckBox_Base}"
                                DockPanel.Dock="Left"
                                Margin="0,0,10,0"
                                VerticalAlignment="Center"
                                Color="{StaticResource H_Color_Primary_White}">
                            <FZMaterial.Preset>
                                <FZMaterialPresetRoundtangleStroke Thickness="2" />
                            </FZMaterial.Preset>
                            <FZMaterial x:Name="Check"
                                        Style="{StaticResource A_Style_FZMaterial_FestivalPass_CheckBox_Tick}"
                                        Visibility="{Binding ProgressState, Converter={StaticResource A_Converter_PlaylistCollectionState_to_Visibility}}">
                            </FZMaterial>
                        </FZMaterial>
                        <FZTextBlock x:Name="ProgressText"
                                    DockPanel.Dock="Right"
                                    VerticalAlignment="Center"
                                    CapHeight="16"
                                    FontFamily="Horizon_A"
                                    Style="{StaticResource A_Style_FZTextBlock_ProgressSlider_ValueText}"
                                    MultiStringFormatter.Param0="{Binding CurrentPoints, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}}"
                                    MultiStringFormatter.Param1="{Binding MaxPoints, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}}"/>

                        <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_Upgrade_Tiles}"
                                    Text="{Binding ProgressState, Converter={StaticResource A_Converter_PlaylistCollectionState_to_StateText}}"
                                    VerticalAlignment="Center"/>
                    </DockPanel>
                </StackPanel>
                <ControlTemplate.Triggers>
                    <DataTrigger Binding="{Binding ProgressState}" Value="{x:Static FestivalPlaylistProgressState.Invalid}">
                        <Setter Property="Visibility" Value="Collapsed"/>
                    </DataTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <ControlTemplate x:Key="A_Template_Control_Upsell_CarPack" TargetType="Control">
                <ControlTemplate.Resources>
                    <Style x:Key="A_Style_FZTextBlock_CarPackName" TargetType="FZTextBlock"
                        BasedOn="{StaticResource A_Style_FZTextBlock_Upgrade_Tiles}">
                        <Setter Property="VerticalAlignment" Value="Center"/>
                        <Setter Property="Color" Value="{StaticResource H_Color_Primary_Green}"/>
                        <Setter Property="AutoScroll" Value="{StaticResource H_AutoScrollSettings_Horizontal_Title}"/>
                        <Setter Property="AutoScroll.AllowScrolling" Value="True"/>
                        <Setter Property="Stretch" Value="None"/>
                    </Style>
                </ControlTemplate.Resources>
                <StackPanel>
                    <FZMaterial Height="2"
                                Opacity="0.2"/>
                    <Decorator Height="50">
                        <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_CarPackName}"
                                     Text="{Binding CarPackName}"/>
                    </Decorator>
                </StackPanel>
            </ControlTemplate>

            <MappingConverter x:Key="A_Converter_SIDIMode_to_Templates">
                <MappingConverterEntry Key="{x:Static ViewCarMode.TreasureCar}" Value="{StaticResource A_Template_Control_TreasureCar_Collected}"/>
                <MappingConverterEntry Key="{x:Static ViewCarMode.Aftermarket}" Value="{StaticResource A_Template_Control_AfterMarket_CarPurchase}"/>
                <MappingConverterEntry Key="{x:Static ViewCarMode.FestivalPlaylistUpsell}" Value="{StaticResource A_Template_Control_Upsell_FestivalPlaylist}"/>
                <MappingConverterEntry Key="{x:Static ViewCarMode.CarPackUpsell}" Value="{StaticResource A_Template_Control_Upsell_CarPack}"/>
            </MappingConverter>

            <!-- Copied here because dynamic resource is not working and Roundtangle is incorrect for Forza Edition  -->
            <Style x:Key="A_Style_FZMaterial_SIDI_RewardBacking" TargetType="local:FZMaterial">
                <Style.Resources>
                    <ResourceDictionary>
                        <CornerRadius x:Key="A_CornerRadius_RewardBacking">2,2,2,2</CornerRadius>

                        <FZMaterialPresetRoundtangle
                            x:Key="A_Preset_Reward_Gradient"
                            BasedOn="{StaticResource H_Roundtangle_Outer_3px}"
                            CornerRadius="{StaticResource A_CornerRadius_RewardBacking}"
                            GradientAngle="90"/>
                        <FZMaterialPresetRoundtangle
                            x:Key="A_Preset_HorizonEdition_Gradient"
                            BasedOn="{StaticResource A_Preset_Reward_Gradient}"
                            GradientColorA="{StaticResource A_Color_HorizonEditionGradientA}"
                            GradientColorB="{StaticResource A_Color_HorizonEditionGradientB}" />

                        <MappingConverter x:Key="A_Converter_RarityToPreset" Default="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_InnerInnerAll}">
                            <MappingConverterEntry Key="{x:Static XAMLRarity.HorizonEdition}" Value="{StaticResource A_Preset_HorizonEdition_Gradient}" />
                        </MappingConverter>
                    </ResourceDictionary>
                </Style.Resources>
                <Setter 
                    Property="Preset"
                    Value="{Binding Rarity, Converter={StaticResource A_Converter_RarityToPreset}}" />
                <Setter
                    Property="Color"
                    Value="{Binding Rarity, Converter={StaticResource A_Converter_RarityToColor}}" />
                <Style.Triggers>
                    <DataTrigger
                        Binding="{Binding RewardType, Converter={StaticResource A_Converter_RewardTypeShouldUseNoRarityColor}}"
                        Value="{StaticResource A_Boolean_True}">
                        <Setter
                            Property="Color"
                            Value="{StaticResource A_Color_NonRarity_Reward}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_CarRarity" TargetType="local:FZTextBlock"
                BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}">
                <Setter Property="CapHeight" Value="20" />
                <Setter Property="Color" Value="{Binding Rarity, Converter={StaticResource A_Converter_CarRarityToTextColor}}" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="HorizontalAlignment" Value="Center" />
                <Setter Property="Margin" Value="7,6" />
                <Setter Property="AutoScroll" Value="{StaticResource H_AutoScrollSettings_Horizontal_Title}" />
                <Setter Property="AutoScroll.AllowScrolling" Value="True" />
            </Style>

            <Style x:Key="A_Style_Control_SIDI_DriveTrain" TargetType="Control"
                BasedOn="{StaticResource A_Style_Control_DriveTrainDisplay}">
                <Style.Resources>
                    <Style x:Key="A_Dynamic_Style_FZMaterial_DriveTrain_background" TargetType="FZMaterial">
                        <Setter Property="Preset" Value="{StaticResource H_Roundtangle_Outer_2px}"/>
                    </Style>
                </Style.Resources>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="HorizontalAlignment" Value="Right"/>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_SIDI_Description" TargetType="FZTextBlock"
                BasedOn="{StaticResource A_Style_FZTextBlock_HorizonB}">
                <Setter Property="CapHeight" Value="16"/>
                <Setter Property="AutoScroll" Value="{StaticResource A_AutoScrollSettings_CarDescription}"/>
                <Setter Property="AutoScroll.AllowScrolling" Value="True"/>
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_White}"/>
                <Setter Property="VerticalAlignment" Value="Top"/>
                <Setter Property="HorizontalAlignment" Value="Stretch"/>
                <Setter Property="Text" Value="{Binding Description}"/>
                <Setter Property="Stretch" Value="None"/>
                <Setter Property="TextWrapping" Value="Wrap"/>
                <Setter Property="Margin" Value="0,8"/>
                <Setter Property="LineAdjust" Value="-0.5"/>
            </Style>

            <ControlTemplate x:Key="A_ControlTemplate_Aftermarket_CarStats" TargetType="Control">
                <StackPanel Orientation="Vertical">
                    <Grid VerticalAlignment="Stretch">
                        <Grid Margin="0,0,0,0"
                              x:Name="Bars"
                              Visibility="Visible"
                              DataContext="{Binding CarStats}">
                            <StackPanel Orientation="Vertical">
                                <Control Template="{StaticResource A_Template_Control_Column_Titles}" 
                                         BindingProxy.B="{Loc CarFlow.IDS_Aftermarket_Title_Current}"
                                         BindingProxy.A="{Loc CarFlow.IDS_Aftermarket_Title_Stock}"
                                         Tag="{Loc CarFlow.IDS_Aftermarket_Title_Stats}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                         BindingProxy.A="{Binding Current.SpeedRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                         BindingProxy.B="{Binding Upgraded.SpeedRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                         BindingProxy.C="{Binding SpeedRatingChange}"
                                         Tag="{Loc CarFlow.IDS_Stat_Speed}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                         BindingProxy.A="{Binding Current.HandlingRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                         BindingProxy.B="{Binding Upgraded.HandlingRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                         BindingProxy.C="{Binding HandlingRatingChange}"
                                         Tag="{Loc CarFlow.IDS_Stat_Handling}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                         BindingProxy.A="{Binding Current.AccelerationRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                         BindingProxy.B="{Binding Upgraded.AccelerationRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                         BindingProxy.C="{Binding AccelerationRatingChange}"
                                         Tag="{Loc CarFlow.IDS_Stat_Accel}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                         BindingProxy.A="{Binding Current.LaunchRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                         BindingProxy.B="{Binding Upgraded.LaunchRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                         BindingProxy.C="{Binding LaunchRatingChange}"
                                         Tag="{Loc CarFlow.IDS_Stat_Launch}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                         BindingProxy.A="{Binding Current.BrakingRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                         BindingProxy.B="{Binding Upgraded.BrakingRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                         BindingProxy.C="{Binding BrakingRatingChange}"
                                         Tag="{Loc CarFlow.IDS_Stat_Braking}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                         BindingProxy.A="{Binding Current.OffroadRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                         BindingProxy.B="{Binding Upgraded.OffroadRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                         BindingProxy.C="{Binding OffroadRatingChange}"
                                         Tag="{Loc CarFlow.IDS_Stat_Offroad}" />
                            </StackPanel>
                        </Grid>
                    </Grid>
                </StackPanel>
            </ControlTemplate>

            <ControlTemplate x:Key="A_ControlTemplate_Aftermarket_PerformanceStats" TargetType="Control">
                <StackPanel Orientation="Vertical">
                    <Grid VerticalAlignment="Stretch">
                        <Grid Margin="0,0,0,0"
                              x:Name="Bars"
                              Visibility="Visible"
                              DataContext="{Binding CarStats}">
                            <StackPanel Orientation="Vertical">
                                <Control Template="{StaticResource A_Template_Control_Column_Titles}" 
                                         BindingProxy.B="{Loc CarFlow.IDS_Aftermarket_Title_Current}"
                                         Tag="{Loc CarFlow.IDS_Aftermarket_Title_Stats}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                         BindingProxy.B="{Binding Upgraded.SimPeakPower, ConverterParameter=power, Converter={NumUnitConverter FractionDigits=0}}"
                                         BindingProxy.C="{Binding SimPeakPowerChange}"
                                         Tag="{Loc CarFlow.IDS_Stat_Power}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                         BindingProxy.B="{Binding Upgraded.SimPeakTorque, ConverterParameter=torque, Converter={NumUnitConverter FractionDigits=0}}"
                                         BindingProxy.C="{Binding SimPeakTorqueChange}"
                                         Tag="{Loc CarFlow.IDS_Stat_Torque}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                         BindingProxy.B="{Binding Upgraded.CurbWeight, ConverterParameter=mass, Converter={NumUnitConverter FractionDigits=0}}"
                                         BindingProxy.C="{Binding CurbWeightChange}"
                                         Tag="{Loc CarFlow.IDS_Stat_Weight}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                         BindingProxy.B="{Binding Upgraded.WeightDistribution, ConverterParameter=fracpercentage, Converter={NumUnitConverter FractionDigits=0}}"
                                         BindingProxy.C="{Binding WeightDistributionChange}"
                                         Tag="{Loc CarFlow.IDS_Stat_Front}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                         BindingProxy.B="{Binding Upgraded.Displacement, ConverterParameter=displacement, Converter={NumUnitConverter FractionDigits=2}}"
                                         BindingProxy.C="{Binding DisplacementChange}"
                                         Tag="{Loc CarFlow.IDS_Stat_Displacement}"/>
                            </StackPanel>
                        </Grid>
                    </Grid>
                </StackPanel>
            </ControlTemplate>

            <ControlTemplate x:Key="A_ControlTemplate_SIDI_Description" TargetType="Control">
                <ControlTemplate.Resources>
                    <Style x:Key="A_Style_FZMaterial_Car_Manufacturer_Bucket_Icon" TargetType="FZMaterial">
                        <Setter Property="Width" Value="182"/>
                        <Setter Property="Height" Value="182"/>
                        <Setter Property="HorizontalAlignment" Value="Center"/>
                        <Setter Property="Visibility" Value="{Binding Downloaded, Converter={StaticResource A_Converter_BoolToVis}, RelativeSource={RelativeSource Self}}"/>
                    </Style>

                    <FZMaterialPresetRoundtangleStroke x:Key="A_FZMaterialPresetRoundtangleStroke_Icon_Boarder"
                        CornerRadius="{StaticResource H_CornerRadius_All_2px}"
                        Thickness="2" />

                    <Style x:Key="A_Style_FZMaterial_Icon_Border" TargetType="FZMaterial">
                        <Setter Property="HorizontalAlignment" Value="Center"/>
                        <Setter Property="Preset" Value="{StaticResource A_FZMaterialPresetRoundtangleStroke_Icon_Boarder}"/>
                        <Setter Property="Color" Value="{StaticResource H_Color_Grey}"/>
                    </Style>
                </ControlTemplate.Resources>
                <DockPanel>
                    <StackPanel DockPanel.Dock="Bottom"
                                Orientation="Horizontal"
                                HorizontalAlignment="Center">
                        <FZMaterial Style="{StaticResource A_Style_FZMaterial_Icon_Border}">
                            <FZMaterial ImageSource="{Binding CarBucketIcon}"
                                        Style="{StaticResource A_Style_FZMaterial_Car_Manufacturer_Bucket_Icon}"/>
                        </FZMaterial>
                        <Decorator Width="48"/>
                        <FZMaterial Style="{StaticResource A_Style_FZMaterial_Icon_Border}">
                            <FZMaterial ImageSource="{Binding CarManufacturerIcon}"
                                        Style="{StaticResource A_Style_FZMaterial_Car_Manufacturer_Bucket_Icon}"/>
                        </FZMaterial>
                    </StackPanel>
                    <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_SIDI_Description}"
                                 DockPanel.Dock="Top"/>
                </DockPanel>
            </ControlTemplate>

            <ControlTemplate x:Key="A_ControlTemplate_Default_Current_CarStats_With_Description" TargetType="Control">
                <DockPanel>
                    <Grid VerticalAlignment="Stretch"
                          DockPanel.Dock="Top">
                        <Grid Margin="0,0,0,0"
                              x:Name="Bars"
                              Visibility="Visible"
                              DataContext="{Binding CarStats.Upgraded}">
                            <StackPanel Orientation="Vertical">
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                            local:BindingProxy.B="{Binding SpeedRating,Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                            Tag="{local:Loc CarFlow.IDS_Stat_Speed}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                            local:BindingProxy.B="{Binding HandlingRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                            Tag="{local:Loc CarFlow.IDS_Stat_Handling}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                            local:BindingProxy.B="{Binding AccelerationRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                            Tag="{local:Loc CarFlow.IDS_Stat_Accel}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                            local:BindingProxy.B="{Binding LaunchRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                            Tag="{local:Loc CarFlow.IDS_Stat_Launch}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                            local:BindingProxy.B="{Binding BrakingRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                            Tag="{local:Loc CarFlow.IDS_Stat_Braking}"/>
                                <Control Template="{StaticResource A_Template_Control_Upgrades_Bars}" 
                                            local:BindingProxy.B="{Binding OffroadRating, Converter={StaticResource A_NumUnitConverter_NoUnit_1dp}}"
                                            Tag="{local:Loc CarFlow.IDS_Stat_Offroad}" />
                            </StackPanel>
                        </Grid>
                    </Grid>
                    <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_SIDI_Description}"
                                 DockPanel.Dock="Bottom"/>
                </DockPanel>
            </ControlTemplate>

            <MappingConverter x:Key="A_Converter_SIDIInfoViewState_to_CarStats_Templates" Default="{StaticResource A_ControlTemplate_Default_Current_CarStats_With_Description}">
                <MappingConverterEntry Key="{x:Static SIDIInfoViewState.Combined}" Value="{StaticResource A_ControlTemplate_Default_Current_CarStats_With_Description}"/>
                <MappingConverterEntry Key="{x:Static SIDIInfoViewState.Stats}" Value="{StaticResource A_ControlTemplate_Aftermarket_CarStats}"/>
                <MappingConverterEntry Key="{x:Static SIDIInfoViewState.PerformanceStats}" Value="{StaticResource A_ControlTemplate_Aftermarket_PerformanceStats}"/>
                <MappingConverterEntry Key="{x:Static SIDIInfoViewState.Description}" Value="{StaticResource A_ControlTemplate_SIDI_Description}"/>
            </MappingConverter>
        </ResourceDictionary>
    </Page.Resources>
    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}" />
    </local:UIPageTransitionManager.TransitionManager>
    <Grid>
        <Grid Style="{StaticResource A_Style_FrameworkElement_FadeOnlyTransition}">
            <local:PlayerBarControl Style="{StaticResource A_Style_PlayerBarControl}"
                                    x:Name="PART_TopBar" />
        </Grid>

        <RoutedEventCommand x:Name="ToggleStatsRoutedEventCommand"
                            RoutedEvent="UIElement.MouseLeftButtonDown"
                            Command="{Binding ToggleStatsCommand}" />

        <ContentControl x:Name="BottomBar"
                        Style="{StaticResource A_Style_ButtonBar}">
            <local:ControllerButtonPanel x:Name="PART_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 Style="{StaticResource A_Style_ControllerButtonControl_Default}"
                                               Button="RThumb_Right"
                                               InputOverride="{Input Command=INPUTCMD_UI_RIGHT_STICK_RIGHT, Context=INPUTCONTEXT_UI}"
                                               Description="{Loc SeeItDriveIt.IDS_Aftermarket_ButtonBar_ShowStats}"
                                               RoutedEventCommand.Action="{Binding ElementName=ToggleStatsRoutedEventCommand}" 
                                               Visibility="{Binding ShowToggleCommand, Converter={StaticResource A_Converter_BoolToVis}}"/>
            </local:ControllerButtonPanel>
        </ContentControl>

        <Border Style="{StaticResource A_Style_Border_ScenePadding_SIDIPurchaseCar}">
            <StackPanel Orientation="Vertical"
                        Width="500"
                        HorizontalAlignment="Left"
                        Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                <!-- Title -->
                <ContentControl Content="{Binding ViewCarTitle}"
                                Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                Margin="0,0,0,8" />
                <DockPanel Margin="0,0,0,0">
                    <local:FZMaterial Style="{StaticResource H_Style_Container_GlassMediumBlur_Description}"
                                      x:Name="CarInfoContainer"
                                      Visibility="Visible"
                                      DockPanel.Dock="Top"
                                      Height="152"
                                      Margin="0,0,0,6">
                        <StackPanel Orientation="Vertical"
                                    Margin="24,20">
                            <local:FZTextBlock Text="{Binding ShortName, Converter={StaticResource A_StringToUpper}}"
                                               CapHeight="26"
                                               Color="{StaticResource H_Color_Primary_White}"/>
                            <Decorator Height="9"/>
                            <local:FZTextBlock Color="{StaticResource H_Color_Primary_Grey_70pc}"
                                               FontFamily="Horizon_B"
                                               CapHeight="26">
                                <local:FZRun Text="{Binding CarYear}" />
                                <local:FZRun Text=" " />
                                <local:FZRun Text="{Binding CarManufacturer, Converter={StaticResource A_StringToUpper}}"/>
                            </local:FZTextBlock>
                            <Decorator Height="15"/>
                            <DockPanel HorizontalAlignment="Left"
                                       VerticalAlignment="Center">

                                <Control DockPanel.Dock="Right"
                                         DataContext="{Binding CarStats.Upgraded}"
                                         Style="{StaticResource A_Style_Control_SIDI_DriveTrain}"
                                         Height="35"
                                         Margin="3,0,0,0"/>

                                <DockPanel DockPanel.Dock="Right"
                                           Visibility="{Binding TireLevel, Converter={StaticResource H_Converter_TyreLevelToIconVisibility}}"
                                           VerticalAlignment="Center"
                                           Margin="3,0">
                                    <Grid DockPanel.Dock="Left"
                                          Width="35"
                                          Height="35"
                                          Margin="0,0,0,0">
                                        <local:FZMaterial Preset="{StaticResource H_Roundtangle_Outer_2px}"
                                                          Color="{StaticResource H_Color_Primary_White}" />
                                        <local:FZMaterial Preset="{StaticResource H_Roundtangle_Outer_2px}"
                                                          Color="{StaticResource H_Color_Primary_Black}"
                                                          ImageSource="{Binding TireLevel, Converter={StaticResource H_Converter_TyreLevelToIcon}}" />
                                    </Grid>
                                </DockPanel>

                                <Control DockPanel.Dock="Right"
                                         Style="{StaticResource H_Style_TemplatedElement_CarClassBadge}"
                                         VerticalAlignment="Center"
                                         local:BindingProxy.A="{Binding CarPI}"
                                         local:BindingProxy.B="{Binding CarClass}"
                                         Height="35"
                                         x:Name="CarClassControl"
                                         Margin="3,0"/>

                                <Grid DockPanel.Dock="Left"
                                      Height="35"
                                      MinWidth="100"
                                      Margin="0,0,3,0">
                                    <FZMaterial Style="{StaticResource A_Style_FZMaterial_SIDI_RewardBacking}">
                                        <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_CarRarity}"
                                                     Stretch="None"
                                                     Text="{Binding Rarity, Converter={StaticResource A_Converter_RarityToNameString}}"/>
                                    </FZMaterial>
                                </Grid>
                            </DockPanel>
                        </StackPanel>
                    </local:FZMaterial>

                    <local:FZMaterial x:Name="InfoPanel"
                                      Style="{StaticResource H_Style_Container_GlassMediumBlur_Description}"
                                      DockPanel.Dock="Top"
                                      Margin="0,0,0,5"
                                      Height="465"
                                      RoutedEventCommand.Action="{Binding ElementName=ToggleStatsRoutedEventCommand}">
                        <DockPanel Margin="24,16,24,0"
                                   MinHeight="448">
                            <Control Template="{Binding SIDIMode, Converter={StaticResource A_Converter_SIDIMode_to_Templates}}"
                                     DockPanel.Dock="Bottom"/>
                            <Control Style="{StaticResource A_Style_Control_SelectionDots}"
                                     DockPanel.Dock="Bottom"/>
                            <Control Template="{Binding InfoView, Converter={StaticResource A_Converter_SIDIInfoViewState_to_CarStats_Templates}}"
                                     DockPanel.Dock="Top"/>
                        </DockPanel>
                    </local:FZMaterial>
                </DockPanel>
                <local:CommonListBox Style="{StaticResource A_Style_ListBox_TextMenu}"
                                     SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"
                                     ItemContainerStyle="{StaticResource A_Style_ListBoxItem_TextMenu_PurchaseOption}"
                                     ItemTemplate="{StaticResource A_DataTemplate_TextMenu_PurchaseDetails}"
                                     ItemsSource="{Binding Collection}"
                                     x:Name="PART_List"
                                     local:FocusOnPageFocusGained.SelectorSelectedItem="True">
                    <local:CommonListBox.Resources>
                        <Thickness x:Key="A_Thickness_ScrollViewer_TextMenu_Margin_Dynamic">-18,-18,-18,-18</Thickness>
                        <Thickness x:Key="A_Thickness_ListBox_TextMenu_PanelMargin_Dynamic">18,18,18,18</Thickness>
                    </local:CommonListBox.Resources>
                </local:CommonListBox>
            </StackPanel>
        </Border>
    </Grid>
</Page>
