<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_CarRestrictionsSelect"
      mc:Ignorable="d"
      DataContext="{Binding RelativeSource={RelativeSource Self}}"
      Style="{StaticResource A_Style_Page_Generic}">
 
    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}"/>
    </local:UIPageTransitionManager.TransitionManager>

    <Page.Resources>
        <ResourceDictionary>
            <System:Double x:Key="A_Double_CarRestrictions_TileSize">260</System:Double>
            <System:Double x:Key="A_Double_CarRestrictions_TileSize_Mfr">128</System:Double>
            <System:Double x:Key="A_Double_CarRestrictions_TileSizeWithPadding">264</System:Double>
            <System:Double x:Key="A_Double_CarRestrictions_TileSizeWithPadding_Mfr">132</System:Double>

            <System:Double x:Key="A_Double_CarRestritions_TilePanelWidth">1056</System:Double>
            <System:Double x:Key="A_Double_CarRestritions_TilePanelWidthWithoutMargin">1052</System:Double>
            <System:Double x:Key="A_Double_CarRestritions_TilePanelHeightWithExternalPadding">556</System:Double>

            <FZMaterialPresetGlassRoundtangle x:Key="A_FZMaterialPresetGlassRoundtangle_RestrictionTile"
                BasedOn="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_OuterAll}"
                CornerRadius="{StaticResource H_CornerRadius_All_3px}" />
            
            <Style x:Key="A_Style_FZMaterial_CarRestriction_Tile_Background" BasedOn="{StaticResource A_Style_FZMaterial_Tile_Background}"
                   TargetType="local:FZMaterial">
                <Setter Property="VerticalAlignment" Value="Stretch"/>
                <Setter Property="HorizontalAlignment" Value="Stretch"/>
                <Setter Property="Color"
                        Value="{StaticResource A_Color_GlassPanel_NonInteractive}"/>
                <Setter Property="Preset"
                        Value="{StaticResource A_FZMaterialPresetGlassRoundtangle_RestrictionTile}" />
            </Style>

            <FZMaterialPresetGlassRoundtangle x:Key="A_FZMaterialPresetGlassRoundtangle_Empty_RestrictionTile"
                                              BasedOn="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_Base}"
                                              CornerRadius="{StaticResource H_CornerRadius_All_3px}" />

            <Style x:Key="A_Style_ListBoxItem_CarRestriction_Empty" TargetType="ListBoxItem">
                <Setter Property="Height" Value="{StaticResource A_Double_CarRestrictions_TileSize}" />
                <Setter Property="Width" Value="{StaticResource A_Double_CarRestrictions_TileSize}" />
                <Setter Property="Focusable" Value="False"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListBoxItem}">
                            <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_TileEmpty_Background}"
                                              Preset="{StaticResource A_FZMaterialPresetGlassRoundtangle_Empty_RestrictionTile}"
                                              VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <ControlTemplate x:Key="A_Control_Tile_CarClass_Pills" TargetType="Control">
                    <Grid>
                    <Control x:Name="ShowdownPill" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  Height="44" Width="Auto" Margin="0,0,-2,0" Template="{StaticResource A_Control_Showdown_Pill}" Visibility="Collapsed"/>
                    </Grid>
                <ControlTemplate.Triggers>
                    <!--  9 is actually the Id assigned to an item when it is Showdown event. Should be CarClass::Max + 1 -->
                    <DataTrigger Binding="{Binding Id}" Value="9">
                        <Setter Property="Visibility" TargetName="ShowdownPill" Value="Visible"/>
                    </DataTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
            
            <Style x:Key="A_Style_CarClassRestriction_CarClass_Pill" TargetType="Control">
                <Setter Property="Visibility" Value="Collapsed"/>
                <Setter Property="Template" Value="{StaticResource A_Control_Tile_CarClass_Pills}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding SceneEnum, RelativeSource={RelativeSource AncestorType=Page}}" Value="{x:Static local:SceneEntryEnum.CarClassRestrictionsSelect}">
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            
            <Style x:Key="A_Style_ListBoxItem_CarRestriction_Empty_Mfr" TargetType="ListBoxItem" BasedOn="{StaticResource A_Style_ListBoxItem_CarRestriction_Empty}">
                <Setter Property="Height" Value="{StaticResource A_Double_CarRestrictions_TileSize_Mfr}" />
                <Setter Property="Width" Value="{StaticResource A_Double_CarRestrictions_TileSize_Mfr}" />
            </Style>

            <Style x:Key="A_Style_ListBoxItem_CarRestriction" TargetType="ListBoxItem">
                <Setter Property="Height" Value="{StaticResource A_Double_CarRestrictions_TileSize}" />
                <Setter Property="Width" Value="{StaticResource A_Double_CarRestrictions_TileSize}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ListBoxItem">
                            <Grid x:Name="Grid_Container" RenderTransformOrigin="0.5,0.5">
                                <Grid.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform/>
                                        <SkewTransform/>
                                        <RotateTransform/>
                                        <TranslateTransform/>
                                    </TransformGroup>
                                </Grid.RenderTransform>

                                <local:FZMaterial x:Name="DropShadow" Style="{StaticResource A_Style_FZMaterial_TileDropShadow}" IsHitTestVisible="False"/>

                                <local:RoutedEventCommand x:Name="SelectItemRoutedEventCommand"
                                                          RoutedEvent="UIElement.MouseLeftButtonUp"
                                                          Command="{Binding SelectCommand, RelativeSource={RelativeSource AncestorType=Page}}" />

                                <Grid x:Name="ScaledContainer"
                                      RenderTransformOrigin="0.5,0.5"
                                      local:ZPanel.ZOffset="0"
                                      Effect="{StaticResource A_MotionBlurEffect}"
                                      local:RoutedEventCommand.Action="{Binding ElementName=SelectItemRoutedEventCommand}">
                                    <Grid.RenderTransform>
                                        <ScaleTransform />
                                    </Grid.RenderTransform>

                                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_MotionBlurExpander}"/>

                                    <local:FZMaterial x:Name="Background" Style="{StaticResource A_Style_FZMaterial_CarRestriction_Tile_Background}"/>

                                    <Grid x:Name="ImageBorder" Margin="0">
                                        <ContentPresenter />
                                        <Control Style="{StaticResource A_Style_CarClassRestriction_CarClass_Pill}"
                                                 VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="10,8"/>
                                    </Grid>

                                    <StrokeHighlightControl x:Name="FocusHighlight" Style="{StaticResource A_Style_ContentControl_TileSelectionStroke}" ContentRadius="4" IsHitTestVisible="False"/>
                                </Grid>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsKeyboardFocused" Value="True">
                                    <Setter TargetName="ImageBorder" Property="Margin" Value="0,0,0,0"/>
                                    <Setter Property="Panel.ZIndex" Value="20"/>
                                    <Setter Property="local:ZPanel.DisableClipping" TargetName="ScaledContainer" Value="True"/>
                                    <Setter Property="Selector.IsSelected"
                                            Value="True"/>
                                </Trigger>
                                <Trigger Property="IsMouseOver"
                                         Value="True">
                                    <Setter Property="FocusManager.FocusedElement"
                                                 Value="{Binding RelativeSource={RelativeSource Self}}" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style x:Key="A_Style_ListBoxItem_CarRestriction_Mfr" BasedOn="{StaticResource A_Style_ListBoxItem_CarRestriction}" TargetType="ListBoxItem">
                <Setter Property="Height" Value="{StaticResource A_Double_CarRestrictions_TileSize_Mfr}" />
                <Setter Property="Width" Value="{StaticResource A_Double_CarRestrictions_TileSize_Mfr}" />
                <Setter Property="local:BindingProxy.A">
                    <Setter.Value>
                        <System:Boolean>True</System:Boolean>
                    </Setter.Value>
                </Setter>
            </Style>

            <DataTemplate x:Key="A_DataTemplate_ListBoxItem_CarRestriction">
                <local:FZMaterial x:Name="Icon" Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_InnerAll}"
                                  ImageSource="{Binding IconPath}"
                                  Stretch="Uniform">
                    <local:FZTextBlock x:Name="Text"
                                       Text="{Binding Name}"
                                       TextAlignment="Center"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       TextWrapping="WrapWithOverflow" 
                                       Color="{StaticResource H_Color_Primary_White}"
                                       FontFamily="Horizon_C"
                                       FontSize="55"
                                       CapHeight="35"
                                       LineAdjust="-0.75"
                                       Visibility="Hidden"/>
                </local:FZMaterial>
                <DataTemplate.Triggers>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding Id}" Value="-1"/>
                            <Condition Binding="{Binding AllowNameTextVisibility}" Value="True"/>
                        </MultiDataTrigger.Conditions>
                        <Setter Property="Visibility" TargetName="Text" Value="Visible" />
                    </MultiDataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <DataTemplate x:Key="A_DataTemplate_ListBoxItem_CarRestriction_Mfr">
                <local:FZMaterial ImageSource="{Binding IconPath}"
                                  Stretch="Uniform"
                                  Margin="5"/>
            </DataTemplate>

            <Style x:Key="A_Style_FZScrollViewer_CarRestrictions_Horizontal" TargetType="{x:Type local:FZScrollViewer}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type local:FZScrollViewer}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>

                                <ScrollBar Grid.Row="1" x:Name="PART_HorizontalScrollBar" Width="Auto" Height="8" Orientation="Horizontal" Margin="2,-19,2,0" VerticalAlignment="Top"
                                            Value="{TemplateBinding HorizontalOffset}" Minimum="0" Maximum="{TemplateBinding ScrollableWidth}" ViewportSize="{TemplateBinding ViewportWidth}"
                                            Style="{StaticResource A_Style_ScrollBar_Default}" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />

                                <ScrollContentPresenter Grid.Row="0" Content="{TemplateBinding Content}" CanContentScroll="{TemplateBinding local:FZScrollViewer.CanContentScroll}"/>


                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="local:FZScrollViewer.Orientation" Value="Horizontal" />
                <Setter Property="Focusable" Value="False"/>
                <Setter Property="HorizontalScrollBarVisibility" Value="{Binding (local:FZScrollViewer.HorizontalScrollBarVisibility), RelativeSource={RelativeSource TemplatedParent}}" />
                <Setter Property="VerticalScrollBarVisibility" Value="Disabled" />
            </Style>

            <Style x:Key="A_Style_FZVirtualizingTilePanel_CarRestriction" TargetType="{x:Type local:FZVirtualizingTilePanel}">
                <Setter Property="IsItemsHost" Value="True"/>
                <Setter Property="Orientation" Value="Horizontal"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="Height" Value="{StaticResource A_Double_CarRestritions_TilePanelHeightWithExternalPadding}"/>
                <Setter Property="Width" Value="{StaticResource A_Double_CarRestritions_TilePanelWidth}"/>
            </Style>

            <ControlTemplate x:Key="A_ControlTemplate_ListBox_CarRestriction" TargetType="ListBox">
                <local:FZScrollViewer Width="{StaticResource A_Double_CarRestritions_TilePanelWidth}"
                                      Style="{StaticResource A_Style_FZScrollViewer_CarRestrictions_Horizontal}"
                                      KeepSelectionOnScreen="True">
                    <local:FZVirtualizingTilePanel Style="{StaticResource A_Style_FZVirtualizingTilePanel_CarRestriction}"
                                                 ChildWidth="{StaticResource A_Double_CarRestrictions_TileSizeWithPadding}"
                                                 ChildHeight="{StaticResource A_Double_CarRestrictions_TileSizeWithPadding}"/>
                </local:FZScrollViewer>
            </ControlTemplate>

            <ControlTemplate x:Key="A_ControlTemplate_ListBox_CarRestriction_Mfr" TargetType="ListBox">
                <local:FZScrollViewer Width="{StaticResource A_Double_CarRestritions_TilePanelWidth}"
                                      Style="{StaticResource A_Style_FZScrollViewer_CarRestrictions_Horizontal}"
                                      KeepSelectionOnScreen="True">
                    <local:FZVirtualizingTilePanel Style="{StaticResource A_Style_FZVirtualizingTilePanel_CarRestriction}"
                                                 ChildWidth="{StaticResource A_Double_CarRestrictions_TileSizeWithPadding_Mfr}"
                                                 ChildHeight="{StaticResource A_Double_CarRestrictions_TileSizeWithPadding_Mfr}"/>
                </local:FZScrollViewer>
            </ControlTemplate>
            
            <Style x:Key="A_Style_ListBox_CarRestriction" TargetType="ListBox">
                <Setter Property="Template" Value="{StaticResource A_ControlTemplate_ListBox_CarRestriction}" />
                <Setter Property="ItemTemplate" Value="{StaticResource A_DataTemplate_ListBoxItem_CarRestriction}" />
                <Setter Property="ItemContainerStyle" Value="{StaticResource A_Style_ListBoxItem_CarRestriction}" />
                <Setter Property="local:FZScrollViewer.CanContentScroll" Value="true"/>
                <Setter Property="local:FZScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
                <Style.Triggers>
                    <Trigger Property="Tag">
                        <Trigger.Value>
                            <local:CarRestrictionsCategory>Manufacturer</local:CarRestrictionsCategory>
                        </Trigger.Value>
                        <Setter Property="Template" Value="{StaticResource A_ControlTemplate_ListBox_CarRestriction_Mfr}"/>
                        <Setter Property="ItemTemplate" Value="{StaticResource A_DataTemplate_ListBoxItem_CarRestriction_Mfr}"/>
                        <Setter Property="ItemContainerStyle" Value="{StaticResource A_Style_ListBoxItem_CarRestriction_Mfr}" />
                    </Trigger>
                </Style.Triggers>
            </Style>
            
            <Style x:Key="A_Style_ListBox_CarRestriction_EmptyItems" TargetType="ListBox">
                <Setter Property="local:FZScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
                <Setter Property="ItemContainerStyle" Value="{StaticResource A_Style_ListBoxItem_CarRestriction_Empty}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ListBox">
                            <Decorator ClipToBounds="True">
                                <local:FZVirtualizingTilePanel Style="{StaticResource A_Style_FZVirtualizingTilePanel_CarRestriction}"
                                                             ChildWidth="{StaticResource A_Double_CarRestrictions_TileSizeWithPadding}"
                                                             ChildHeight="{StaticResource A_Double_CarRestrictions_TileSizeWithPadding}"/>
                            </Decorator>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="Tag">
                        <Trigger.Value>
                            <local:CarRestrictionsCategory>Manufacturer</local:CarRestrictionsCategory>
                        </Trigger.Value>
                        <Setter Property="ItemContainerStyle" Value="{StaticResource A_Style_ListBoxItem_CarRestriction_Empty_Mfr}" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBox">
                                    <Decorator ClipToBounds="True">
                                        <local:FZVirtualizingTilePanel Style="{StaticResource A_Style_FZVirtualizingTilePanel_CarRestriction}"
                                                                     ChildWidth="{StaticResource A_Double_CarRestrictions_TileSizeWithPadding_Mfr}"
                                                                     ChildHeight="{StaticResource A_Double_CarRestrictions_TileSizeWithPadding_Mfr}"/>
                                    </Decorator>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_CarEligibilityValue" TargetType="local:FZTextBlock">
                <Setter Property="TextAlignment" Value="Center" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="CapHeight" Value="18" />
                <Setter Property="FontFamily" Value="Horizon_A"/>
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_Black}" />
                <Style.Triggers>
                    <Trigger Property="Text" Value="-1">
                        <Setter Property="Visibility" Value="Hidden" />
                    </Trigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_CarEligibilityLabel" TargetType="local:FZTextBlock">
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="TextWrapping" Value="NoWrap" />
                <Setter Property="CapHeight" Value="18" />
                <Setter Property="FontFamily" Value="Horizon_A"/>
                <Setter Property="FontSize" Value="22" />
                <Setter Property="Margin" Value="12,12,24,12"/>
                <Setter Property="Color" Value="{StaticResource A_Color_White}" />
            </Style>

            <Style x:Key="A_Style_FZMaterial_GlassPanel_Left_White"
                   TargetType="{x:Type local:FZMaterial}"
                   BasedOn="{StaticResource A_Style_FZMaterial_GlassPanel_Left}">
                <Setter Property="Color" Value="{StaticResource A_Color_GlassPanel_Interactive}"/>
            </Style>

            <Style x:Key="A_Style_FZMaterial_CarCountContainer_Panel" TargetType="local:FZMaterial">
                <Setter Property="Width" Value="44"/>
                <Setter Property="Height" Value="44"/>
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_Green}"/>
                <Setter Property="Preset" Value="{StaticResource H_Roundtangle_LeftOnly_1px}"/>
            </Style>
            <Style x:Key="A_Style_FZMaterial_CarCount_MessagePanel" TargetType="local:FZMaterial">
                <Setter Property="Width" Value="480"/>
                <Setter Property="Height" Value="44"/>
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_Black}"/>
                <Setter Property="Preset" Value="{StaticResource H_Roundtangle_RightOnly_1px}"/>
            </Style>
            
            <ControlTemplate x:Key="A_Control_Eligible_Car_Panel">
                <StackPanel Orientation="Horizontal">
                    <Grid>
                        <local:FZMaterial x:Name="BackgroundPanel" Style="{StaticResource A_Style_FZMaterial_CarCountContainer_Panel}">
                            <local:FZTextBlock x:Name="EligibleCarCount"
                                               Text="{Binding NumCarsEligible}"
                                               Style="{StaticResource A_Style_FZTextBlock_CarEligibilityValue}"/>
                        </local:FZMaterial>
                    </Grid>
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CarCount_MessagePanel}">
                            <local:FZTextBlock x:Name="AutoshowText" Text="{local:Loc CarFlow.IDS_EligibleAutoshowCars}" Style="{StaticResource A_Style_FZTextBlock_CarEligibilityLabel}" />
                    </local:FZMaterial>
                </StackPanel>
                <ControlTemplate.Triggers>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding SceneEnum, RelativeSource={RelativeSource AncestorType=Page}}" Value="{x:Static local:SceneEntryEnum.CarClassRestrictionsSelect}"/>
                            <Condition Binding="{Binding CampaignSetup.CarPIRestriction}" Value="-1" />
                        </MultiDataTrigger.Conditions>
                        <Setter Property="Text" Value="{local:Loc EventBlueprint.IDS_CarClassAnyDescription}" TargetName="AutoshowText"/>
                        <Setter Property="Style" Value="{StaticResource A_Style_FZMaterial_GlassPanel_Left_White}" TargetName="BackgroundPanel"/>
                        <Setter Property="Visibility" Value="Hidden" TargetName="EligibleCarCount"/>
                    </MultiDataTrigger>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding SceneEnum, RelativeSource={RelativeSource AncestorType=Page}}" Value="{x:Static local:SceneEntryEnum.CarClassRestrictionsSelect}"/>
                            <Condition Binding="{Binding CampaignSetup.IsShowdown}" Value="True"/>
                        </MultiDataTrigger.Conditions>
                        <Setter Property="Text" Value="{local:Loc EventBlueprint.IDS_CarClassShowdownDescription}" TargetName="AutoshowText"/>
                        <Setter Property="Style" Value="{StaticResource A_Style_FZMaterial_GlassPanel_Left_White}" TargetName="BackgroundPanel"/>
                        <Setter Property="Visibility" Value="Hidden" TargetName="EligibleCarCount"/>
                    </MultiDataTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <Style x:Key="A_FrameworkElement_ShowWhenCustomTabSelected" TargetType="FrameworkElement">
                <Setter Property="Visibility" Value="Collapsed" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding SelectedItem.CategoryId, ElementName=PART_CarRestrictionCategoryList}">
                        <DataTrigger.Value>
                            <local:CarRestrictionsCategory>Custom</local:CarRestrictionsCategory>
                        </DataTrigger.Value>
                        <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            
            <Style x:Key="A_FrameworkElement_HideWhenCustomTabSelected" TargetType="FrameworkElement">
                <Setter Property="Visibility" Value="Visible" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding SelectedItem.CategoryId, ElementName=PART_CarRestrictionCategoryList}">
                        <DataTrigger.Value>
                            <local:CarRestrictionsCategory>Custom</local:CarRestrictionsCategory>
                        </DataTrigger.Value>
                        <Setter Property="Visibility" Value="Collapsed" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

        </ResourceDictionary>
    </Page.Resources>

    <Grid>
        <Control Style="{StaticResource A_Style_Control_ScreenBackground}"/>

        <!-- Bars -->
        <local:PlayerBarControl x:Name="TopBar" Style="{StaticResource A_Style_PlayerBarControl}" />
        <ContentControl Style="{StaticResource A_Style_ButtonBar}"
                        x:Name="BottomBar">
            <local:ControllerButtonPanel x:Name="PART_HelpPanel"
                                         Style="{StaticResource A_Style_ControllerButtonPanel_Default}"
                                         local:ScreenReader.InterruptBehavior="WaitForNonePlaying">
                <local:ControllerButtonControl Button="A"
                                               Description="{local:Loc HelpButtons.IDS_Select}" />
                <local:ControllerButtonControl Button="B"
                                               Description="{local:Loc HelpButtons.IDS_Back}" />
                <local:ControllerButtonControl Button="X"
                                               Visibility="{Binding CanViewCars, Converter={StaticResource A_FZBooleanToVisibilityConverter}, FallbackValue=Collapsed}"
                                               Description="{local:Loc HelpButtons.IDS_ViewCars}"/>
            </local:ControllerButtonPanel>
        </ContentControl>
        <local:NetworkCountdownControl Style="{StaticResource A_Style_NetworkCountdownControl_EventSetup}" />

        <Grid x:Name="PART_LayoutRoot">
            <Border Style="{StaticResource A_Style_Border_ScenePadding_Opus}">
                <DockPanel Margin="23,0,16,10" Height="836"
                           HorizontalAlignment="Center">
                    <DockPanel HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="0,0,0,88">
                        <Decorator Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                                   DockPanel.Dock="Top">
                            <ContentControl Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                            Content="{Binding Title}"
                                            local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Blueprint.png"
                                            HorizontalAlignment="Left" />
                        </Decorator>
                        
                        <Decorator
                            Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_1}"
                            Width="{StaticResource A_Double_CarRestritions_TilePanelWidthWithoutMargin}"
                            DockPanel.Dock="Top">
                            <FZButtonsSelector
                                x:Name="PART_CarRestrictionCategoryList"
                                Style="{StaticResource H_Style_TabBar_Scrolling}"
                                ItemsSource="{Binding Categories}"
                                SelectedIndex="-1"
                                Width="{StaticResource A_Double_CarRestritions_TilePanelWidthWithoutMargin}"
                                local:ScreenReader.LineType="SelectedGroup"
                                local:ScreenReader.Event="OnChange"
                                local:ScreenReader.Line="{Binding SelectedItem.Title, RelativeSource={RelativeSource Self}}"
                                local:ScreenReader.SelectedNumber="{Binding SelectedIndex, RelativeSource={RelativeSource Self}, Converter={StaticResource A_IndexToNumberConverter}, FallbackValue=-1}"
                                local:ScreenReader.SelectedCount="{Binding Categories.Count}">
                                <FZButtonsSelector.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <VirtualizingScrollPanel
                                            Style="{StaticResource H_Style_MotionBlurScrollPanel_TabBar}"
                                            ItemWidth="226"
                                            Padding="226,0,0,0"/>
                                    </ItemsPanelTemplate>
                                </FZButtonsSelector.ItemsPanel>
                            </FZButtonsSelector>
                        </Decorator>
                        
                        <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_3}"
                              DockPanel.Dock="Bottom"
                              VerticalAlignment="Top"
                              HorizontalAlignment="Left">
                            <Decorator Style="{StaticResource A_FrameworkElement_HideWhenCustomTabSelected}"
                                   Width="{StaticResource A_Double_CarRestritions_TilePanelWidth}">
                                <StackPanel Orientation="Horizontal">
                                    <StackPanel Margin="0,0,6,0" Orientation="Horizontal">
                                        <local:FZMaterial Width="44" Height="44" Style="{StaticResource A_Style_FZMaterial_CarCountContainer_Panel}">
                                            <local:FZTextBlock Text="{Binding NumGarageCarsEligible}"
                                                       Style="{StaticResource A_Style_FZTextBlock_CarEligibilityValue}"/>
                                        </local:FZMaterial>
                                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CarCount_MessagePanel}">
                                                <local:FZTextBlock Text="{local:Loc CarFlow.IDS_EligibleGarageCars}" 
                                                    Style="{StaticResource A_Style_FZTextBlock_CarEligibilityLabel}" />
                                        </local:FZMaterial>
                                    </StackPanel>
                                    <Control Template="{StaticResource A_Control_Eligible_Car_Panel}"/>
                                </StackPanel>
                            </Decorator>
                            
                            <Decorator Style="{StaticResource A_FrameworkElement_ShowWhenCustomTabSelected}"
                                       Width="{StaticResource A_Double_CarRestritions_TilePanelWidth}"
                                       Height="44">
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_Pill}" Margin="4,0,4,0">
                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_DescriptionBlockBody}"
                                                   DataContext="{Binding (local:AttachedTileMenu.TileMenuNavigationManager).SelectedTile}"
                                                   Text="{local:Loc EventBlueprint.IDS_CustomCarRestrictions_Description}"
                                                   VerticalAlignment="Center"
                                                   Margin="24,0,24,0"
                                                   TextWrapping="Wrap"/>
                                </local:FZMaterial>
                            </Decorator>
                        </Grid>

                        <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_2}" 
                              Width="{StaticResource A_Double_CarRestritions_TilePanelWidth}" Margin="0,0,0,0"
                              VerticalAlignment="Bottom"
                              Height="{StaticResource A_Double_CarRestritions_TilePanelHeightWithExternalPadding}">
                                <local:CommonListBox Style="{StaticResource A_Style_ListBox_CarRestriction_EmptyItems}"
                                                 Tag="{Binding SelectedItem.CategoryId, ElementName=PART_CarRestrictionCategoryList}">
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                                <Control/>
                            </local:CommonListBox>
                            <local:CommonListBox x:Name="PART_CarRestrictionItemList" 
                                                 Style="{StaticResource A_Style_ListBox_CarRestriction}" 
                                                 HorizontalAlignment="Left"
                                                 ItemsSource="{Binding SelectedItem.Items, ElementName=PART_CarRestrictionCategoryList}"
                                                 Tag="{Binding SelectedItem.CategoryId, ElementName=PART_CarRestrictionCategoryList}"
                                                 AllowMouseWheelScrolling="False"
                                                 local:ScreenReader.LineType="SelectedItem"
                                                 local:ScreenReader.Event="OnChange"
                                                 local:ScreenReader.Line="{Binding SelectedItem.Name, RelativeSource={RelativeSource Self}}"
                                                 local:ScreenReader.SelectedNumber="{Binding SelectedIndex, RelativeSource={RelativeSource Self}, Converter={StaticResource A_IndexToNumberConverter}, FallbackValue=-1}"
                                                 local:ScreenReader.SelectedCount="{Binding SelectedItem.Items.Count, ElementName=PART_CarRestrictionCategoryList}"/>
                        </Grid>
                    </DockPanel>

                    <Decorator Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                               DockPanel.Dock="Right"
                               HorizontalAlignment="Left"
                               Margin="0,0,0,88"
                               VerticalAlignment="Bottom">
                        <Grid Margin="12,0">
                            <Decorator Style="{StaticResource A_FrameworkElement_HideWhenCustomTabSelected}">
                                <ContentControl  x:Name="PART_Flyer"
                                             Style="{StaticResource A_Style_ContentControl_CampaignFlyerFront}"
                                             DataContext="{Binding CampaignSetup}" />
                            </Decorator>

                            <Decorator Style="{StaticResource A_FrameworkElement_ShowWhenCustomTabSelected}">
                                <Grid>
                                    <local:FZMaterial Height="{StaticResource A_Double_CampaignSetupFlyerHeight}"
                                          Width="{StaticResource A_Double_CampaignSetupFlyerWidth}" 
                                        Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlyerBorder}" 
                                    ImageSourceNoPreload="/ForzaUI;component/Textures/Data_Bound/Event_Blueprint/Backgrounds/Custom/Custom_Car_Bucket_Poster.png" />

                                    <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/FestivalPass/Reward_Car_Obscured.png"
                                                      Margin="0,120,0,0"
                                                      VerticalAlignment="Top"
                                                      HorizontalAlignment="Center"
                                                      Width="442"
                                                      Height="248"
                                                      Stretch="Uniform"
                                                       />

                                    <local:FZTextBlock Text="{local:Loc EventBlueprint.IDS_CustomCarRestrictions_FlyerText}"
                                       Style="{StaticResource A_Style_FZTextBlock_HorizonA}" 
                                       Color="#000000" FontSize="40"
                                       VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0,0,0,104" />

                                    <local:FZTextBlock Text="{local:Loc EventBlueprint.IDS_CustomizeCarRestrictions_FlyerText}"
                                       Style="{StaticResource A_Style_FZTextBlock_HorizonB}" 
                                       Color="#000000" FontSize="25"
                                       VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0,0,0,68" />
                                </Grid>
                            </Decorator>
                        </Grid>
                    </Decorator>
                </DockPanel>
            </Border>
        </Grid>
    </Grid>
</Page>