<Page xmlns:local="clr-namespace:ForzaUI"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      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"
      x:Class="ForzaUI.A_LoadSaveTuning"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}"
      >
    
    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}"/>
    </local:UIPageTransitionManager.TransitionManager>

    <Page.Resources>
        <ResourceDictionary>
            <local:NumUnitConverter x:Key="A_LoadSaveTuning_NumUnitConverter_CarStat"
                                    FractionDigits="0"
                                    ShowUnit="true" />

            <GridLength x:Key="A_GridLength_ItemSpacing">1</GridLength>

            <System:Int32 x:Key="A_Int32_Row_Header">0</System:Int32>
            <System:Int32 x:Key="A_Int32_Row_Power">2</System:Int32>
            <System:Int32 x:Key="A_Int32_Row_Power_Spacing">3</System:Int32>
            <System:Int32 x:Key="A_Int32_Row_Torque">4</System:Int32>
            <System:Int32 x:Key="A_Int32_Row_Torque_Spacing">5</System:Int32>
            <System:Int32 x:Key="A_Int32_Row_Weight">6</System:Int32>
            <System:Int32 x:Key="A_Int32_Row_Weight_Spacing">7</System:Int32>
            <System:Int32 x:Key="A_Int32_Row_Front">8</System:Int32>
            <System:Int32 x:Key="A_Int32_Row_Front_Spacing">9</System:Int32>
            <System:Int32 x:Key="A_Int32_Row_Displacement">10</System:Int32>
            <System:Int32 x:Key="A_Int32_Row_Displacement_Spacing">11</System:Int32>
            <System:Int32 x:Key="A_Int32_Row_Class">12</System:Int32>

            <System:Int32 x:Key="A_Int32_Column_CarStat">1</System:Int32>
            <System:Int32 x:Key="A_Int32_Column_Previous">2</System:Int32>
            <System:Int32 x:Key="A_Int32_Column_New">3</System:Int32>
            <System:Int32 x:Key="A_Int32_Column_Result">4</System:Int32>

            <Style x:Key="A_Style_FZTextBlock_LoadSaveTuning_Header"
                   TargetType="local:FZTextBlock"
                   BasedOn="{StaticResource A_Style_FZTextBlock_HeaderBlock}">
                <Setter Property="Margin"
                        Value="0" />
                <Setter Property="HorizontalAlignment"
                        Value="Center" />
            </Style>

            <Style x:Key="A_Style_FZTextBlock_LoadSaveTuning_StatInfoHeader" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_Heading_Small}">
                <Setter Property="Color" Value="{StaticResource A_Color_SubHeader_Text}" />
                <Setter Property="HorizontalAlignment" Value="Left" />
                <Setter Property="VerticalAlignment" Value="Center" />

                <Setter Property="Stretch" Value="Uniform" />
                <Setter Property="StretchDirection" Value="DownOnly" />
                <Setter Property="MaxWidth" Value="200" />
                <Setter Property="CapHeight" Value="17" />
            </Style>

            <Style x:Key="A_Style_FZTextBlock_LoadSaveTuning_StatInfoPrevious" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_Heading_Medium}">
                <!-- BUG 180616 Requested we remove the opacity/dimming. Keeping this code in case we choose to revive this-->
                <!--<Style.Triggers>
                    <Trigger Property="Tag">
                        <Trigger.Value>
                            <System:Boolean>True</System:Boolean>
                        </Trigger.Value>
                        <Setter Property="Color" Value="{StaticResource A_Color_Background_Text}" />
                    </Trigger>
                </Style.Triggers>-->
                <Setter Property="Tag" Value="{Binding DataContext.IsNewItem, RelativeSource={RelativeSource AncestorType=DockPanel}}" />
                <Setter Property="HorizontalAlignment" Value="Center" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="Color" Value="{StaticResource A_Color_SubHeader_Text}" />

                <Setter Property="Stretch" Value="Uniform" />
                <Setter Property="StretchDirection" Value="DownOnly" />
                <Setter Property="MaxWidth" Value="200" />
                <Setter Property="Grid.Column"
                        Value="{StaticResource A_Int32_Column_Previous}" />
                <Setter Property="Margin"
                        Value="0" />
                <Setter Property="CapHeight" Value="17" />
            </Style>

            <Style x:Key="A_Style_FZMaterial_PerformanceChangeArrowBox_New"
                   BasedOn="{StaticResource A_Style_FZMaterial_FlatPanel_Base}"
                   TargetType="local:FZMaterial">
                <Setter Property="Color"
                        Value="#00FFFFFF" />
                <Setter Property="Preset"
                        Value="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_InnerAll}" />
                <Setter Property="Height"
                        Value="35" />
                <Setter Property="HorizontalAlignment"
                        Value="Center" />
                <Style.Triggers>
                    <Trigger Property="Tag">
                        <Trigger.Value>
                            <System:Int32>-1</System:Int32>
                            <!-- -1 IsNegative -->
                        </Trigger.Value>
                        <Setter Property="Color"
                                Value="{StaticResource A_Color_Stat_Negative}" />
                    </Trigger>
                    <Trigger Property="Tag">
                        <Trigger.Value>
                            <System:Int32>1</System:Int32>
                            <!-- 1 IsPositive -->
                        </Trigger.Value>
                        <Setter Property="Color"
                                Value="{StaticResource A_Color_Stat_Positive}" />
                    </Trigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_LoadSaveTuning_StatInfoNew" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_Heading}">
                <Setter Property="HorizontalAlignment" Value="Center" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="CapHeight" Value="17" />
                <Setter Property="Stretch" Value="Uniform" />
                <Setter Property="StretchDirection" Value="DownOnly" />
                <Setter Property="MaxWidth" Value="200" />
                <Setter Property="Margin" Value="10,5,10,5" />
                <Setter Property="Color"
                        Value="{StaticResource A_Color_Stat_Neutral_Light}" />
            </Style>

            <Style x:Key="A_Style_Progressbar_TuneSetup_SmallSpinner" TargetType="ProgressBar" BasedOn="{StaticResource A_Style_Progressbar_Loading_SmallSpinner}">
                <Setter Property="Visibility" Value="Collapsed"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding FetchingItems, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}}" Value="True">
                        <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding HasItems, ElementName=ItemList}" Value="True">
                        <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_NoTuneSetups_HeaderBlock" TargetType="{x:Type local:FZTextBlock}" BasedOn="{StaticResource A_Style_FZTextBlock_HeaderBlock}">
                <Setter Property="Color"
                        Value="{StaticResource A_Color_SubHeader_Text}" />
                <Setter Property="Visibility" Value="Collapsed"/>
                <Style.Triggers>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding HasItems, ElementName=ItemList}" Value="False"/>
                            <Condition Binding="{Binding FetchingItems, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}}" Value="False"/>
                        </MultiDataTrigger.Conditions>
                        <Setter Property="Visibility" Value="Visible" />
                    </MultiDataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_Grid_HideIfNoCategories"
                   BasedOn="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                   TargetType="Grid">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=(ItemsControl.Items).(ItemCollection.Count), ElementName=CategoryList, Converter={StaticResource A_CompareConverter}, ConverterParameter=2}"
                                 Value="-1">
                        <Setter Property="Visibility"
                                Value="Collapsed" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_InfoLabel_Tuning"
                   TargetType="local:FZTextBlock"
                   BasedOn="{StaticResource A_Style_FZTextBlock_Heading_Minimum}">
                <Setter Property="Color"
                        Value="{StaticResource A_Color_SubHeader_Text}" />
                <Setter Property="HorizontalAlignment"
                        Value="Left" />
                <Setter Property="VerticalAlignment"
                        Value="Center" />
                <Setter Property="Margin"
                        Value="0,0,0,10" />
                <Setter Property="CapHeight"
                        Value="16" />
            </Style>

            <Style x:Key="A_Style_FZTextBlock_InfoValue_Tuning"
                   TargetType="local:FZTextBlock"
                   BasedOn="{StaticResource A_Style_FZTextBlock_InfoLabel_Tuning}">
                <Setter Property="HorizontalAlignment"
                        Value="Left" />
                <Setter Property="FontFamily"
                        Value="Horizon_B" />
                <Setter Property="CapHeight"
                        Value="22" />
                <Setter Property="Margin"
                        Value="0,0,0,20" />
            </Style>

            <Style x:Key="A_Style_FZMaterial_RowSeparator"
                   TargetType="{x:Type local:FZMaterial}">
                <Setter Property="Margin"
                        Value="25,0,25,0" />
                <Setter Property="VerticalAlignment"
                        Value="Bottom" />
                <Setter Property="Color"
                        Value="#FFFFFFFF" />
                <Setter Property="Height"
                        Value="1" />
                <Setter Property="Opacity"
                        Value="0.5" />
                <Setter Property="Grid.ColumnSpan"
                        Value="6" />
            </Style>

            <DataTemplate x:Key="A_DataTemplate_Carousel_SimpleCarItem_Tuning">
                <Grid>
                    <local:FZMaterial x:Name="Icon"
                                      ImageSource="{Binding Thumbnail}"
                                      Margin="20"
                                      Stretch="Uniform" />
                    <StackPanel Orientation="Horizontal"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Bottom"
                                Margin="6"
                                Visibility="{Binding IsNewItem, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}">
                        <Viewbox Height="32">
                            <Control Style="{StaticResource A_Style_Control_CarClassBadge_Small}"
                                     Name="CarClassBadge"
                                     local:BindingProxy.A="{Binding Stats.Upgraded.PerformanceIndex}"
                                     local:BindingProxy.B="{Binding Stats.Upgraded.ClassID}" />
                        </Viewbox>
                    </StackPanel>
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding IsNewItem}" Value="True">
                        <Setter TargetName="Icon" Property="Margin" Value="-10" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding IsSavingMode, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}}" Value="True">
                        <Setter TargetName="CarClassBadge" Property="local:BindingProxy.A" Value="{Binding Stats.Current.PerformanceIndex}"/>
                        <Setter TargetName="CarClassBadge" Property="local:BindingProxy.B" Value="{Binding Stats.Current.ClassID}"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <Style x:Key="A_Style_FZMaterial_PerformanceChangeArrowBox"
                   BasedOn="{StaticResource A_Style_FZMaterial_FlatPanel_Base}"
                   TargetType="local:FZMaterial">
                <Setter Property="Color"
                        Value="{StaticResource A_Color_Stat_Neutral_Light}" />
                <Setter Property="Preset"
                        Value="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_InnerAll}" />
                <Setter Property="Height"
                        Value="35" />
                <Setter Property="Width"
                        Value="43" />
                <Style.Triggers>
                    <Trigger Property="Tag">
                        <Trigger.Value>
                            <System:Int32>-1</System:Int32>
                            <!-- -1 IsNegative -->
                        </Trigger.Value>
                        <Setter Property="Color"
                                Value="{StaticResource A_Color_Stat_Negative}" />
                    </Trigger>
                    <Trigger Property="Tag">
                        <Trigger.Value>
                            <System:Int32>1</System:Int32>
                            <!-- 1 IsPositive -->
                        </Trigger.Value>
                        <Setter Property="Color"
                                Value="{StaticResource A_Color_Stat_Positive}" />
                    </Trigger>
                </Style.Triggers>
            </Style>

            <ControlTemplate x:Key="A_ControlTemplate_PerformanceChangeBox">
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PerformanceChangeArrowBox}"
                                  Tag="{TemplateBinding Tag}">
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_FloatingIconShadow}">
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PerformanceChangeArrow}"
                                          Tag="{TemplateBinding Tag}" />
                    </local:FZMaterial>
                </local:FZMaterial>
            </ControlTemplate>

        </ResourceDictionary>
    </Page.Resources>

    <Grid x:Name="LayoutRoot">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="TypeStateGroup">
                <VisualState x:Name="TuneState" />
            </VisualStateGroup>
            <VisualStateGroup x:Name="CurationAvailabilityStateGroup">
                <VisualState x:Name="CurationAvailableState"/>
                <VisualState x:Name="CurationUnavailableState">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="CategoryList">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(ContentControl.Content)"
                                                       Storyboard.TargetName="ContentControl_SceneTitle">
                            <DiscreteStringKeyFrame KeyTime="0"
                                                    Value="{local:Loc Tuning.IDS_Save_Title}" />
                        </StringAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

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

        <!-- Help Bar -->
        <ContentControl Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl x:Name="DefaultHelpPanel" Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
        </ContentControl>

        <Border Style="{StaticResource A_Style_Border_ScenePadding_Opus}">
            <StackPanel Style="{StaticResource A_Style_FrameworkElement_ScreenTilt}"
                        VerticalAlignment="Center"
                        Margin="0,0,0,-2">
                <Decorator Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                    <ContentControl x:Name="ContentControl_SceneTitle" Content="{Binding Title}" 
                                Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Tuning.png" 
                                HorizontalAlignment="Left"
                                />
                </Decorator>

                <Grid Style="{StaticResource A_Style_Grid_HideIfNoCategories}">
                    <local:ItemsSelector x:Name="CategoryList"
                                         ItemsSource="{Binding Categories}"
                                         Style="{StaticResource A_Style_ItemsSelector_UGCPopupTabBar}"/>
                </Grid>

                <DockPanel x:Name="MainContent"
                      DataContext="{Binding SelectedItem, ElementName=ItemList}"
                      Height="500">
                    <DockPanel x:Name="LeftPanel"
                               DockPanel.Dock="Left"
                               Margin="0,0,10,0"
                               Width="370"
                               Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_2}">
                        <ContentControl DockPanel.Dock="Top"
                                        Content="{Binding DisplayName}"
                                        Style="{StaticResource A_Style_ContentControl_Header}" />
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_BodyPanel}">
                            <Grid Margin="25">
                                <DockPanel Visibility="{Binding HasLeftPanelLoaded, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden}}">
                                    <DockPanel LastChildFill="False">
                                        <local:FZMaterial DockPanel.Dock="Bottom"
                                                          Style="{StaticResource A_Style_FZMaterial_FlatPanel_FooterPanel}"
                                                          Color="#FFFFFFFF"
                                                          Margin="-25,0,-25,-25"
                                                          MinHeight="69">
                                            <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Popularity}"
                                                                    HorizontalAlignment="Center"
                                                                    VerticalAlignment="Center"
                                                                    BaseValue="{Binding Popularity}"
                                                                    NewValue="{Binding Popularity}" 
                                                                    local:BindingProxy.B="#FF00b592"/>
                                        </local:FZMaterial>
                                        <local:FZMaterial Color="{StaticResource A_Color_Header_Background}"
                                                          Margin="-25,0,-25,0"
                                                          DockPanel.Dock="Bottom">
                                            <local:FZTextBlock Text="{local:Loc Storefront.IDS_LabelPopularity}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoLabel_Tuning}"
                                                               VerticalAlignment="Center"
                                                               HorizontalAlignment="Center"
                                                               CapHeight="16"
                                                               Margin="13" />
                                        </local:FZMaterial>
                                        <StackPanel DockPanel.Dock="Bottom">
                                            <local:FZTextBlock Text="{local:Loc Storefront.IDS_LabelCreator}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoLabel_Tuning}" />
                                            <local:FZTextBlock Text="{Binding UserProfile.FormattedGamertag}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoValue_Tuning}" Margin="0,0,0,10"/>
                                            <Control x:Name="Rating" 
                                                     Template="{StaticResource A_ControlTemplate_RankLevel_Pill}" 
                                                     Tag="{x:Static local:UGCThreadType.Tuning}"
                                                     HorizontalAlignment="Left"
                                                     DataContext="{Binding UserProfile}"
                                                     Margin="0,0,0,20"/>

                                            <local:FZTextBlock Text="{local:Loc Storefront.IDS_LabelDate}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoLabel_Tuning}" />
                                            <local:FZTextBlock Text="{Binding DateCreated}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoValue_Tuning}" />
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal"
                                                    DockPanel.Dock="Top">
                                            <local:FZMaterial VerticalAlignment="Center"
                                                              Width="100"
                                                              Height="100"
                                                              Stretch="Uniform"
                                                              ImageSource="{Binding ManufacturerIconPath}" />
                                            <StackPanel Orientation="Vertical"
                                                        VerticalAlignment="Center"
                                                        Width="260">
                                                <local:FZTextBlock Text="{Binding CarDisplayName, Converter={StaticResource A_StringToUpper}}"
                                                                   Style="{StaticResource A_Style_FZTextBlock_InfoValue_Tuning}" 
                                                                   Margin="10,0,45,5"/>
                                                <local:FZTextBlock Text="{Binding CarYear}"
                                                                   Style="{StaticResource A_Style_FZTextBlock_InfoValue_Tuning}"
                                                                   Margin="10,5,0,0" />
                                            </StackPanel>
                                        </StackPanel>
                                    </DockPanel>
                                </DockPanel>
                                <StackPanel HorizontalAlignment="Center"
                                            VerticalAlignment="Center"
                                            Visibility="{Binding HasLeftPanelLoaded, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}">
                                    <ProgressBar Style="{StaticResource A_Style_Progressbar_TuneSetup_SmallSpinner}" />
                                </StackPanel>
                            </Grid>
                        </local:FZMaterial>
                    </DockPanel>

                    <Grid DockPanel.Dock="Right"
                          Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_3}"
                          Margin="10,0,0,0"
                          Width="370"
                          x:Name="RightPanel">
                        <DockPanel>
                            <ContentControl DockPanel.Dock="Top"
                                            Content="{local:Loc Tuning.IDS_Performance}"
                                            Style="{StaticResource A_Style_ContentControl_Header}" />
                            <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_BodyPanel}">
                                <Grid>
                                    <DockPanel Margin="30"
                                               Visibility="{Binding HasRightPanelLoaded, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden}}">
                                        
                                        <DockPanel DockPanel.Dock="Bottom" Grid.Row="2" LastChildFill="False">
                                            <ContentControl Style="{StaticResource A_Style_Control_CarClassBadge_Small_Default}"
                                                            DataContext="{Binding Stats.Upgraded}"
                                                            DockPanel.Dock="Left"
                                                            local:BindingProxy.A="{Binding PerformanceIndex}"
                                                            local:BindingProxy.B="{Binding ClassID}" />
                                            <Control Style="{StaticResource A_Style_Control_DriveTrainDisplay}"
                                                     DataContext="{Binding Stats.Upgraded}"
                                                     DockPanel.Dock="Right" />
                                        </DockPanel>

                                        <UniformGrid Columns="1"
                                                     x:Name="Grid_PerformanceBars"
                                                     Margin="0,25,0,55"
                                                     DataContext="{Binding Stats}">
                                            <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Speed}" />
                                            <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Handling}" />
                                            <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Acceleration}" />
                                            <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Launch}" />
                                            <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Braking}" />
                                        </UniformGrid>

                                    </DockPanel>
                                    <StackPanel HorizontalAlignment="Center"
                                                VerticalAlignment="Center"
                                                Visibility="{Binding HasRightPanelLoaded, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}">
                                        <ProgressBar Style="{StaticResource A_Style_Progressbar_TuneSetup_SmallSpinner}" />
                                    </StackPanel>
                                </Grid>
                            </local:FZMaterial>
                        </DockPanel>
                    </Grid>
                    
                    <DockPanel x:Name="CenterPanel"
                               Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_2}"
                               Margin="0">
                        <Grid>
                            <Grid DataContext="{Binding Stats}"
                                  Visibility="{Binding HasCenterPanelLoaded, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}">
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_BodyPanel}">
                                    <Grid>
                                        <local:FZTextBlock Text="{local:Loc Storefront.IDS_NoTunesFound}"
                                                           Style="{StaticResource A_Style_FZTextBlock_NoTuneSetups_HeaderBlock}" />
                                        <ProgressBar Style="{StaticResource A_Style_Progressbar_TuneSetup_SmallSpinner}"
                                                     HorizontalAlignment="Center"
                                                     VerticalAlignment="Center"
                                                     Margin="0,72,0,0" />
                                    </Grid>
                                </local:FZMaterial>
                                <ContentControl Style="{StaticResource A_Style_ContentControl_Header_Custom}"
                                                Height="72"
                                                VerticalAlignment="Top" />
                            </Grid>
                            <Grid DataContext="{Binding Stats}"
                                  Visibility="{Binding HasCenterPanelLoaded, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="30" />
                                    <ColumnDefinition Width="300"/>
                                    <ColumnDefinition Width="125"/>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="125" />
                                    <ColumnDefinition Width="30" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="72" />
                                    <RowDefinition Height="{StaticResource A_GridLength_ItemSpacing}" />
                                    <RowDefinition Height="85"/>
                                    <RowDefinition Height="{StaticResource A_GridLength_ItemSpacing}" />
                                    <RowDefinition Height="60"/>
                                    <RowDefinition Height="{StaticResource A_GridLength_ItemSpacing}" />
                                    <RowDefinition Height="60" />
                                    <RowDefinition Height="{StaticResource A_GridLength_ItemSpacing}" />
                                    <RowDefinition Height="60" />
                                    <RowDefinition Height="{StaticResource A_GridLength_ItemSpacing}" />
                                    <RowDefinition Height="60" />
                                    <RowDefinition Height="{StaticResource A_GridLength_ItemSpacing}" />
                                    <RowDefinition Height="96" />
                                </Grid.RowDefinitions>
                                <!-- Header -->
                                <ContentControl Style="{StaticResource A_Style_ContentControl_Header_Custom}"
                                                Grid.Row="0"
                                                Grid.ColumnSpan="6" />
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_BodyPanel}"
                                                  Grid.Row="1"
                                                  Grid.ColumnSpan="6"
                                                  Grid.RowSpan="13" />
                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_Header}"
                                                   Text="{local:Loc Upgrades_flow.IDS_CarStat}"
                                                   Grid.Column="{StaticResource A_Int32_Column_CarStat}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Header}"
                                                   HorizontalAlignment="Left" />
                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_Header}"
                                                   Text="{local:Loc Upgrades_flow.IDS_Previous}"
                                                   Grid.Column="{StaticResource A_Int32_Column_Previous}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Header}" />
                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_Header}"
                                                   Text="{local:Loc Upgrades_flow.IDS_New}"
                                                   Grid.Column="{StaticResource A_Int32_Column_New}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Header}" />
                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_Header}"
                                                   Text="{local:Loc Upgrades_flow.IDS_Result}"
                                                   Grid.Column="{StaticResource A_Int32_Column_Result}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Header}" />

                                <!-- Power -->
                                <local:FZTextBlock Text="{Binding Current.SimPeakPower, ConverterParameter=power, Converter={StaticResource A_LoadSaveTuning_NumUnitConverter_CarStat}, FallbackValue=?}"
                                                   Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoPrevious}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Power}"
                                                   Grid.Column="{StaticResource A_Int32_Column_Previous}"
                                                   VerticalAlignment="Bottom"
                                                   Margin="0,0,0,27" />
                                <local:FZTextBlock Text="{local:Loc CarFlow.IDS_Stat_Power_Upper}"
                                                   Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoHeader}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Power}"
                                                   Grid.Column="{StaticResource A_Int32_Column_CarStat}"
                                                   VerticalAlignment="Bottom"
                                                   Margin="0,0,0,27" />
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PerformanceChangeArrowBox_New}"
                                                  Tag="{Binding SimPeakPowerChange}"
                                                  Grid.Row="{StaticResource A_Int32_Row_Power}"
                                                  Grid.Column="{StaticResource A_Int32_Column_New}"
                                                  VerticalAlignment="Bottom"
                                                  Margin="0,0,0,18">
                                    <local:FZTextBlock Text="{Binding Upgraded.SimPeakPower, ConverterParameter=power, Converter={StaticResource A_LoadSaveTuning_NumUnitConverter_CarStat}, FallbackValue=?}"
                                                       Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoNew}" />
                                </local:FZMaterial>
                                <Control Template="{StaticResource A_ControlTemplate_PerformanceChangeBox}"
                                         Tag="{Binding SimPeakPowerChange}"
                                         Grid.Row="{StaticResource A_Int32_Row_Power}"
                                         Grid.Column="{StaticResource A_Int32_Column_Result}"
                                         VerticalAlignment="Bottom"
                                         Margin="0,0,0,18" />

                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_RowSeparator}"
                                                  Grid.Row="{StaticResource A_Int32_Row_Power_Spacing}" />

                                <!-- Torque-->
                                <local:FZTextBlock Text="{Binding Current.SimPeakTorque, ConverterParameter=torque, Converter={StaticResource A_LoadSaveTuning_NumUnitConverter_CarStat}, FallbackValue=?}"
                                                   Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoPrevious}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Torque}"
                                                   Grid.Column="{StaticResource A_Int32_Column_Previous}" />
                                <local:FZTextBlock Text="{local:Loc CarFlow.IDS_Stat_Torque_Upper}"
                                                   Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoHeader}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Torque}"
                                                   Grid.Column="{StaticResource A_Int32_Column_CarStat}" />
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PerformanceChangeArrowBox_New}"
                                                  Tag="{Binding SimPeakTorqueChange}"
                                                  Grid.Row="{StaticResource A_Int32_Row_Torque}"
                                                  Grid.Column="{StaticResource A_Int32_Column_New}">
                                    <local:FZTextBlock Text="{Binding Upgraded.SimPeakTorque, ConverterParameter=torque, Converter={StaticResource A_LoadSaveTuning_NumUnitConverter_CarStat}, FallbackValue=?}"
                                                       Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoNew}" />
                                </local:FZMaterial>
                                <Control Template="{StaticResource A_ControlTemplate_PerformanceChangeBox}"
                                         Tag="{Binding SimPeakTorqueChange}"
                                         Grid.Row="{StaticResource A_Int32_Row_Torque}"
                                         Grid.Column="{StaticResource A_Int32_Column_Result}" />

                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_RowSeparator}"
                                                  Grid.Row="{StaticResource A_Int32_Row_Torque_Spacing}" />

                                <!-- Weight -->
                                <local:FZTextBlock Text="{Binding Current.CurbWeight, ConverterParameter=mass, Converter={StaticResource A_LoadSaveTuning_NumUnitConverter_CarStat}, FallbackValue=?}"
                                                   Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoPrevious}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Weight}"
                                                   Grid.Column="{StaticResource A_Int32_Column_Previous}" />
                                <local:FZTextBlock Text="{local:Loc CarFlow.IDS_Stat_Weight_Upper}"
                                                   Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoHeader}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Weight}"
                                                   Grid.Column="{StaticResource A_Int32_Column_CarStat}" />
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PerformanceChangeArrowBox_New}"
                                                  Tag="{Binding CurbWeightChange}"
                                                  Grid.Row="{StaticResource A_Int32_Row_Weight}"
                                                  Grid.Column="{StaticResource A_Int32_Column_New}">
                                    <local:FZTextBlock Text="{Binding Upgraded.CurbWeight, ConverterParameter=mass, Converter={StaticResource A_LoadSaveTuning_NumUnitConverter_CarStat}, FallbackValue=?}"
                                                       Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoNew}" />
                                </local:FZMaterial>
                                <Control Template="{StaticResource A_ControlTemplate_PerformanceChangeBox}"
                                         Tag="{Binding CurbWeightChange}"
                                         Grid.Row="{StaticResource A_Int32_Row_Weight}"
                                         Grid.Column="{StaticResource A_Int32_Column_Result}" />

                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_RowSeparator}"
                                                  Grid.Row="{StaticResource A_Int32_Row_Weight_Spacing}" />

                                <!-- Front -->
                                <local:FZTextBlock Text="{Binding Current.WeightDistribution, ConverterParameter=fracpercentage, Converter={StaticResource A_LoadSaveTuning_NumUnitConverter_CarStat}, FallbackValue=?}"
                                                   Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoPrevious}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Front}"
                                                   Grid.Column="{StaticResource A_Int32_Column_Previous}" />
                                <local:FZTextBlock Text="{local:Loc CarFlow.IDS_Stat_Front_Upper}"
                                                   Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoHeader}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Front}"
                                                   Grid.Column="{StaticResource A_Int32_Column_CarStat}" />
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PerformanceChangeArrowBox_New}"
                                                  Tag="{Binding WeightDistributionChange}"
                                                  Grid.Row="{StaticResource A_Int32_Row_Front}"
                                                  Grid.Column="{StaticResource A_Int32_Column_New}">
                                    <local:FZTextBlock Text="{Binding Upgraded.WeightDistribution, ConverterParameter=fracpercentage, Converter={StaticResource A_LoadSaveTuning_NumUnitConverter_CarStat}, FallbackValue=?}"
                                                       Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoNew}" />
                                </local:FZMaterial>
                                <Control Template="{StaticResource A_ControlTemplate_PerformanceChangeBox}"
                                         Tag="{Binding WeightDistributionChange}"
                                         Grid.Row="{StaticResource A_Int32_Row_Front}"
                                         Grid.Column="{StaticResource A_Int32_Column_Result}" />

                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_RowSeparator}"
                                                  Grid.Row="{StaticResource A_Int32_Row_Front_Spacing}" />

                                <!-- Displacement -->
                                <local:FZTextBlock Text="{Binding Current.Displacement, Converter={StaticResource A_LoadSaveTuning_NumUnitConverter_CarStat}, FallbackValue=?}"
                                                   Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoPrevious}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Displacement}"
                                                   Grid.Column="{StaticResource A_Int32_Column_Previous}" />
                                <local:FZTextBlock Text="{local:Loc CarFlow.IDS_Stat_Displacement_Upper}"
                                                   Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoHeader}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Displacement}"
                                                   Grid.Column="{StaticResource A_Int32_Column_CarStat}" />
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PerformanceChangeArrowBox_New}"
                                                  Tag="{Binding DisplacementChange}"
                                                  Grid.Row="{StaticResource A_Int32_Row_Displacement}"
                                                  Grid.Column="{StaticResource A_Int32_Column_New}">
                                    <local:FZTextBlock Text="{Binding Upgraded.Displacement, Converter={StaticResource A_LoadSaveTuning_NumUnitConverter_CarStat}, FallbackValue=?}"
                                                       Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoNew}" />
                                </local:FZMaterial>
                                <Control Template="{StaticResource A_ControlTemplate_PerformanceChangeBox}"
                                         Tag="{Binding DisplacementChange}"
                                         Grid.Row="{StaticResource A_Int32_Row_Displacement}"
                                         Grid.Column="{StaticResource A_Int32_Column_Result}" />

                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_RowSeparator}"
                                                  Grid.Row="{StaticResource A_Int32_Row_Displacement_Spacing}" />

                                <!-- Class -->
                                <Grid Grid.Row="{StaticResource A_Int32_Row_Class}"
                                      Grid.Column="{StaticResource A_Int32_Column_Previous}"
                                      HorizontalAlignment="Center"
                                      Style="{StaticResource A_Style_FrameworkElement_DimOnTagTrue}"
                                      Tag="{Binding DataContext.IsNewItem, RelativeSource={RelativeSource AncestorType=DockPanel}}">
                                    <Control Style="{StaticResource A_Style_Control_CarClassBadge_Small}"
                                             local:BindingProxy.A="{Binding Current.PerformanceIndex}"
                                             local:BindingProxy.B="{Binding Current.ClassID}" />
                                </Grid>

                                <local:FZTextBlock Text="{local:Loc Upgrades_flow.IDS_Class}"
                                                   Style="{StaticResource A_Style_FZTextBlock_LoadSaveTuning_StatInfoHeader}"
                                                   Grid.Row="{StaticResource A_Int32_Row_Class}"
                                                   Grid.Column="{StaticResource A_Int32_Column_CarStat}" />

                                <Grid Grid.Row="{StaticResource A_Int32_Row_Class}"
                                      Grid.Column="{StaticResource A_Int32_Column_New}"
                                      HorizontalAlignment="Center"
                                      Style="{StaticResource A_Style_FrameworkElement_DimOnTagTrue}"
                                      Tag="{Binding DataContext.PerformanceIndexChange, ElementName=CenterPanel}">
                                    <Control Style="{StaticResource A_Style_Control_CarClassBadge_Small}"
                                             HorizontalAlignment="Right"
                                             local:BindingProxy.A="{Binding Upgraded.PerformanceIndex}"
                                             local:BindingProxy.B="{Binding Upgraded.ClassID}" />
                                </Grid>
                                <Control Template="{StaticResource A_ControlTemplate_PerformanceChangeBox}"
                                         Tag="{Binding PerformanceIndexChange}"
                                         Grid.Row="{StaticResource A_Int32_Row_Class}"
                                         Grid.Column="{StaticResource A_Int32_Column_Result}" />

                            </Grid>
                        </Grid>
                    </DockPanel>
                </DockPanel>

                <!-- Carousel -->
                <ContentControl Template="{StaticResource A_Template_ContentControl_SelectorContainer_PageButtons}"
                                Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_3}"
                                KeyboardNavigation.DirectionalNavigation="Contained"
                                Margin="0,11,0,-15">
                    <local:WrapListBox x:Name="ItemList"
                                       ItemsSource="{Binding ItemsCollection}"
                                       Style="{StaticResource A_Style_Carousel_7Item}"
                                       ItemTemplate="{StaticResource A_DataTemplate_Carousel_SimpleCarItem_Tuning}" />
                </ContentControl>
            </StackPanel>
        </Border>
    </Grid>
</Page>
