<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_RivalsLeaderboard"
      mc:Ignorable="d"
	  Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}"
      Name="p1"
      >

    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}"/>
    </local:UIPageTransitionManager.TransitionManager>

    <Page.Resources>
        <ResourceDictionary>
            <Style x:Key="A_Style_FZMaterial_AssistsIconTCS" TargetType="local:FZMaterial" BasedOn="{StaticResource A_Style_FZMaterial_AssistsIcon}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding UsedTCS}" Value="True">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Data_Bound/Checkbox/Radio_On.png" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            <Style x:Key="A_Style_FZMaterial_AssistsIconSTM" TargetType="local:FZMaterial" BasedOn="{StaticResource A_Style_FZMaterial_AssistsIcon}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding UsedSTM}" Value="True">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Data_Bound/Checkbox/Radio_On.png" />
                    </DataTrigger>
                    
                </Style.Triggers>
            </Style>

            <GridLength x:Key="A_GridLength_Column_DriverLevel_Width">75</GridLength>
            <GridLength x:Key="A_GridLength_Column_DriverName_Width">342</GridLength>
            <GridLength x:Key="A_GridLength_Column_CarName_Width">259</GridLength>
            <GridLength x:Key="A_GridLength_Column_CarClass_Width">185</GridLength>
            <GridLength x:Key="A_GridLength_Column_Drivetrain_Width">212</GridLength>
            <GridLength x:Key="A_GridLength_Column_Time_Width">105</GridLength>
            <GridLength x:Key="A_GridLength_Column_ABS_Width">99</GridLength>
            <GridLength x:Key="A_GridLength_Column_TCS_Width">99</GridLength>
            <GridLength x:Key="A_GridLength_Column_STM_Width">99</GridLength>
            <GridLength x:Key="A_GridLength_Column_Gear_Width">99</GridLength>

            <!-- Row Templates -->
            <ControlTemplate x:Key="A_ControlTemplate_HeaderRow" TargetType="Control">
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_FlatPanel_HeaderPill_Green}" >
                    <Grid Margin="0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_DriverLevel_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_DriverName_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_CarName_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_CarClass_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_Drivetrain_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_Time_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_ABS_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_TCS_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_STM_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_Gear_Width}"/>
                        </Grid.ColumnDefinitions>
                        <local:FZTextBlock Grid.Column="1" Text="{local:Loc PreRaceMenu.IDS_StartingGrid_DriverName}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}"    />
                        <local:FZTextBlock Grid.Column="2" Text="{local:Loc PreRaceMenu.IDS_StartingGrid_CarName}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" />
                        <local:FZTextBlock Grid.Column="3" Text="{local:Loc PreRaceMenu.IDS_StartingGrid_Class}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" />
                        <local:FZTextBlock Grid.Column="4" Text="{local:Loc PreRaceMenu.IDS_StartingGrid_Drivetrain}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" Margin="19,0,0,0" />
                        <local:FZTextBlock Grid.Column="5" Text="{local:Loc PreRaceMenu.IDS_StartingGrid_Time}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" />
                        <local:FZTextBlock Grid.Column="6" Text="{local:Loc PreRaceMenu.IDS_StartingGrid_ABS}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" HorizontalAlignment="Center"/>
                        <local:FZTextBlock Grid.Column="7" Text="{local:Loc PreRaceMenu.IDS_StartingGrid_TCS}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" HorizontalAlignment="Center"/>
                        <local:FZTextBlock Grid.Column="8" Text="{local:Loc PreRaceMenu.IDS_StartingGrid_STM}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" HorizontalAlignment="Center"/>
                        <local:FZTextBlock Grid.Column="9" Text="{Convert {local:Loc PreRaceMenu.IDS_StartingGrid_Gear}, Converter={StringToUpper}}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" HorizontalAlignment="Center"/>
                    </Grid>
                </local:FZMaterial>
            </ControlTemplate>

            <ControlTemplate x:Key="A_ControlTemplate_Row" TargetType="ListBoxItem">
                <StackPanel Orientation="Horizontal">
                    <StackPanel Name="Content" Orientation="Horizontal" Visibility="{Binding IsLoading, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden_Inverse}}">
                        <ContentControl Style="{StaticResource A_Style_ContentControl_SelectableRow}">
                            <Grid Margin="0,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_DriverLevel_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_DriverName_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_CarName_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_CarClass_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_Drivetrain_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_Time_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_ABS_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_TCS_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_STM_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_Gear_Width}"/>
                                </Grid.ColumnDefinitions>
                                <ContentControl Grid.Column="0" Template="{StaticResource A_ControlTemplate_Cell_DriverLevel}" HorizontalAlignment="Center"/>
                                <ContentControl Grid.Column="1" Template="{StaticResource A_ControlTemplate_Cell_DriverName}"/>
                                <ContentControl Grid.Column="2" Template="{StaticResource A_ControlTemplate_Cell_CarName}" />
                                <Control Grid.Column="3" Template="{StaticResource A_ControlTemplate_Cell_Class}" HorizontalAlignment="Left" VerticalAlignment="Center" />
                                <ContentControl Grid.Column="4" Template="{StaticResource A_ControlTemplate_Cell_Drivetrain}" HorizontalAlignment="Left"/>
                                <ContentControl Grid.Column="5" Template="{StaticResource A_ControlTemplate_Cell_Time}" />
                                <ContentControl Grid.Column="6" Template="{StaticResource A_ControlTemplate_ABS}" HorizontalAlignment="Center"/>
                                <local:FZMaterial Grid.Column="7" Style="{StaticResource A_Style_FZMaterial_AssistsIconTCS}" HorizontalAlignment="Center"/>
                                <local:FZMaterial Grid.Column="8" Style="{StaticResource A_Style_FZMaterial_AssistsIconSTM}" HorizontalAlignment="Center"/>
                                <local:FZTextBlock Grid.Column="9" Style="{StaticResource A_Style_FZTextBlock_Gear}" HorizontalAlignment="Center"/>
                            </Grid>
                        </ContentControl>
                    </StackPanel>
                </StackPanel>
                <ControlTemplate.Triggers>
                   <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                       <Setter Property="local:ZPanel.ZIndex" Value="1" />
                       <Setter Property="local:ZPanel.ClippingBias"  Value="10" />
                   </DataTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <!-- Row Style -->
            <Style x:Key="A_Style_ListBoxItem_DriverList_StartingGrid" TargetType="ListBoxItem" BasedOn="{StaticResource A_Style_ListBoxItem_LeaderboardBase}">
                <Setter Property="Template" Value="{StaticResource A_ControlTemplate_Row}" />
            </Style>

        </ResourceDictionary>
    </Page.Resources>

    <Border>
        <Grid x:Name="PART_LayoutRoot">
            <!-- Background Blur -->
            <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />

            <ContentControl x:Name="BottomBar" Style="{StaticResource A_Style_ButtonBar}">
                <ContentControl x:Name="PART_DefaultHelpPanel"
                    local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Select}"
                    local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                    local:ControllerButtonPanel.XDescription="{local:Loc HelpButtons.IDS_Filter}"
                    Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
            </ContentControl>

            <Border Style="{StaticResource A_Style_Border_ScenePadding}">
                <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="109,0,0,0">
                    <StackPanel Orientation="Horizontal" Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                        <ContentControl x:Name="TitleBlock"
                                        Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                        Content="{Binding Title}"
                                        Width="364"
                                        Margin="0,0,0,10"
                                        local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Leaderboards.png" />
                    </StackPanel>

                    <StackPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                                HorizontalAlignment="Center">
                        <Control Style="{StaticResource A_Style_HeaderRow}"
                                 Template="{StaticResource A_ControlTemplate_HeaderRow}"
                                 Margin="0,0,0,5"/>
                        <local:CommonListBox x:Name="PART_ListBox_LeaderboardList" 
                                             ItemsSource="{Binding LeadersList}" 
                                             MaxHeight="594"
                                             ItemContainerStyle="{StaticResource A_Style_ListBoxItem_DriverList_StartingGrid}"  
                                             Style="{StaticResource A_Style_CommonListBox_Leaderboard}" 
                                             VerticalAlignment="Top"
                                             VirtualizingStackPanel.VirtualizationMode="Recycling" 
                                             ScrollViewer.CanContentScroll="true"/>
                        <Control Style="{StaticResource A_Style_FooterRow}"
                                 Template="{StaticResource A_ControlTemplate_FooterRow_Default}" />
                    </StackPanel>
                </StackPanel>
            </Border>
        </Grid>
    </Border>
</Page>
