<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="ForzaUI.A_SelectUpgradeArea"
    xmlns:local="clr-namespace:ForzaUI;assembly="
    Style="{StaticResource A_Style_Page_Generic}"
    DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <UIPageTransitionManager.TransitionManager>
        <UIPageTransitionManager
            Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}" />
    </UIPageTransitionManager.TransitionManager>
    <Page.Resources>
        <ResourceDictionary />
    </Page.Resources>
    <Grid>
        <PlayerBarControl
            x:Name="TopBar"
            Style="{StaticResource A_Style_PlayerBarControl}"
            ShowPlayerAndCarInfo="{Binding SeamlessUpgrades, Converter={StaticResource A_Converter_Boolean_Invert}, RelativeSource={RelativeSource AncestorType=Page}}"/>
        <ContentControl
            x:Name="BottomBar"
            Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl
                x:Name="PART_DefaultHelpPanel"
                Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
        </ContentControl>
        <Grid
            x:Name="PART_LayoutRoot"
            Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
            <Grid
                Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                VerticalAlignment="Center"
                Margin="96,0"
                Height="{StaticResource H_Height_Upgrades}">
                <Grid.RowDefinitions>
                    <RowDefinition
                        Height="Auto" />
                    <RowDefinition
                        Height="Auto" />
                    <RowDefinition
                        Height="*" />
                    <RowDefinition
                        Height="Auto" />
                </Grid.RowDefinitions>
                <ContentControl
                    x:Name="Screen_Title"
                    Style="{StaticResource H_Style_TemplatedWrapper_ScreenTitle}"
                    Content="{Binding AreaName, FallbackValue={Loc ScreenTitles.IDS_UpgradeCarMainTitle}}"
                    HorizontalAlignment="Left"
                    Width="{StaticResource H_Width_Upgrades}"
                    Grid.Row="0" />

                <DockPanel Grid.Row="2" 
                           DataContext="{Binding SelectedItem, ElementName=PART_ItemList}"
                           HorizontalAlignment="Left">
                    <ContentControl x:Name="Description"
                                    Style="{StaticResource A_Style_ContentControl_Header_Custom}"
                                    DockPanel.Dock="Top"
                                    HorizontalContentAlignment="Left"
                                    Width="{StaticResource H_Width_Upgrades}">
                        <FZTextBlock Style="{StaticResource H_Style_Text_DescriptionTitle}"
                                     FontFamily="Horizon_A"
                                     Text="{Binding Name}"/>
                    </ContentControl>
                    <ContentControl Template="{StaticResource A_ControlTemplate_SidePanelContent}"
                                    Width="{StaticResource H_Width_Upgrades}"
                                    DockPanel.Dock="Top">
                        <Decorator ClipToBounds="True" Margin="24">
                            <FZTextBlock Style="{StaticResource H_Style_Text_Description_Body_12px_Scrolling}" 
                                         CapHeight="14"
                                         TextAlignment="Left"
                                         Text="{Binding Description}"
                                         Margin="0,4"/>
                        </Decorator>
                    </ContentControl>
                </DockPanel>

                <Control
                    x:Name="Basket"
                    Style="{StaticResource H_Style_TemplatedElement_Basket}"
                    HorizontalAlignment="Left"
                    Width="{StaticResource H_Width_Upgrades}"
                    Grid.Row="3" />
                <DockPanel
                    Margin="0,0,0,4"
                    HorizontalAlignment="Left"
                    Grid.Row="1">
                    <ScrollBar
                        Style="{StaticResource H_Style_ScrollBar}"
                        Margin="8,0,0,0"
                        Minimum="{Binding ScrollWindowMin, ElementName=PART_ItemList}"
                        Maximum="{Binding ScrollWindowMax, ElementName=PART_ItemList}"
                        Value="{Binding ScrollWindowValue, ElementName=PART_ItemList, Mode=TwoWay}"
                        ViewportSize="{Binding ScrollWindowSize, ElementName=PART_ItemList}"
                        DockPanel.Dock="Right">
                        <DynamicData.Data>
                            <DynamicDataItem
                                Name="ScrollBarHideWhenNotNeeded"
                                DataType="Boolean"
                                Value="True" />
                        </DynamicData.Data>
                    </ScrollBar>
                    <WrapListBox
                        x:Name="PART_ItemList"
                        Style="{StaticResource H_Style_UpgradeGrid_Square_3x3}"
                        ScrollOrientation="Vertical"
                        ItemsSource="{Binding Collection}"
                        SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                        RoutedEventCommand.Action="{Binding ElementName=ButtonBarDisableMouseCursorMovement}"
                        RoutedEventCommand.Action2="{Binding ElementName=ButtonBarEnableMouseCursorMovement}" 
                        FocusOnPageFocusGained.SelectorSelectedItem="True"/>
                </DockPanel>
            </Grid>
            <ContentControl Template="{StaticResource A_Template_Control_HudInstruction}" 
                            Content="{Binding SeamlessChallengeObjectiveString}" 
                            Visibility="{Binding SeamlessChallengeObjectiveString, Converter={StaticResource A_StringVisConverter}}"
                            Margin="96,52,0,0" 
                            HorizontalAlignment="Left"/>
            <ContentControl Template="{StaticResource A_ControlTemplate_StoryChallenges}" />
            <RoutedEventCommand
                x:Name="ButtonBarDisableMouseCursorMovement"
                RoutedEvent="UIElement.MouseEnter"
                Command="{Binding DisableCameraFocus, RelativeSource={RelativeSource AncestorType=Page}}" />
            <RoutedEventCommand
                x:Name="ButtonBarEnableMouseCursorMovement"
                RoutedEvent="UIElement.MouseLeave"
                Command="{Binding EnableCameraFocus, RelativeSource={RelativeSource AncestorType=Page}}" />
        </Grid>
    </Grid>
</Page>