<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_GlobalXPLeaderboard"
      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>
            <!-- Converters -->
            <BooleanToVisibilityConverter x:Key="BoolVisConverter"/>
            <local:NumUnitConverter x:Key="A_Converter_NumUnitConverter_Position" MinDigits="2" FractionDigits="0" />

            <!-- Cell Templates -->
            <ControlTemplate x:Key="A_ControlTemplate_Cell_Position">
                <local:FZTextBlock Text="{Binding Position, Converter={StaticResource A_Converter_NumUnitConverter_Position}}" Style="{StaticResource A_Style_FZTextBlock_LeaderboardRow}" />
            </ControlTemplate>

            <ControlTemplate x:Key="A_ControlTemplate_Cell_ClubName">
                <local:FZTextBlock Text="{Binding ClubName}" Style="{StaticResource A_Style_FZTextBlock_LeaderboardRow}" />
            </ControlTemplate>

            <ControlTemplate x:Key="A_ControlTemplate_Cell_TotalXP">
                <local:FZTextBlock Text="{Binding XP, Converter={StaticResource A_NumUnitConverter_XPConverter}}" Style="{StaticResource A_Style_FZTextBlock_LeaderboardRow}" />
            </ControlTemplate>

            <!-- Row Templates -->
            <ControlTemplate x:Key="A_ControlTemplate_HeaderRow" TargetType="ContentControl">
                <local:FZMaterial Color="{StaticResource A_Color_DarkPanelHeader}">
                    <StackPanel Orientation="Horizontal">
                        <ContentControl Content="{local:Loc PreRaceMenu.IDS_StartingGrid_Position}" Style="{StaticResource A_Style_Cell}" Template="{StaticResource A_ControlTemplate_Cell_Header}" Width="{StaticResource A_Size_ColumnWidthSmall}" />
                        <ContentControl Content="{local:Loc PreRaceMenu.IDS_StartingGrid_DriverName}" Style="{StaticResource A_Style_Cell}" Template="{StaticResource A_ControlTemplate_Cell_Header}" Width="299" Margin="110, 0, 25, 0" />
                        <ContentControl Content="{local:Loc PreRaceMenu.IDS_Club}" Style="{StaticResource A_Style_Cell}" Template="{StaticResource A_ControlTemplate_Cell_Header}" Width="{StaticResource A_Size_ColumnWidthLarge}" />
                        <ContentControl Content="{local:Loc PreRaceMenu.IDS_TotalXP}" Style="{StaticResource A_Style_Cell}" Template="{StaticResource A_ControlTemplate_Cell_Header}" Width="{StaticResource A_Size_ColumnWidthLarge}" />
                    </StackPanel>
                </local:FZMaterial>
            </ControlTemplate>



            <ControlTemplate x:Key="A_ControlTemplate_Row" TargetType="ListBoxItem">
                <local:FZMaterial Name="Background" Color="{StaticResource A_Color_Leaderboard_RowBackground}">
                    <Grid>
                        <StackPanel Name="Content" Orientation="Horizontal">
                            <ContentControl Style="{StaticResource A_Style_Cell}" Template="{StaticResource A_ControlTemplate_Cell_Position}" Width="{StaticResource A_Size_ColumnWidthSmall}" />
                            <ContentControl Style="{StaticResource A_Style_Cell}" Template="{StaticResource A_ControlTemplate_Cell_DriverName}" Width="{StaticResource A_Size_ColumnWidthXL}" />
                            <ContentControl Style="{StaticResource A_Style_Cell}" Template="{StaticResource A_ControlTemplate_Cell_ClubName}" Width="{StaticResource A_Size_ColumnWidthLarge}" />
                            <ContentControl Style="{StaticResource A_Style_Cell}" Template="{StaticResource A_ControlTemplate_Cell_TotalXP}" Width="{StaticResource A_Size_ColumnWidthLarge}" />
                        </StackPanel>

                        <local:FZMaterial Name="BorderBottom" Color="{StaticResource A_Color_DarkPanelDividingLine}" Height="2" VerticalAlignment="Bottom" />
                    </Grid>
                </local:FZMaterial>

                <ControlTemplate.Triggers>
                    <Trigger Property="IsSelected" Value="True">
                        <Setter TargetName="Background"
                                Property="Color"
                                Value="{StaticResource A_Color_Leaderboard_SelectedBackground}" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>


            <!-- Footer Stuff -->
            <ControlTemplate x:Key="A_ControlTemplate_FooterRow" TargetType="Control">
                <local:FZMaterial Color="{StaticResource A_Color_DarkPanelHeader}">
                    <Grid>
                        <Control Style="{StaticResource A_Style_Cell}" Template="{StaticResource A_ControlTemplate_FooterRow_Filter}" Width="Auto" />
                        <Control Style="{StaticResource A_Style_Cell}" Template="{StaticResource A_ControlTemplate_FooterRow_TopPosition}" Width="Auto" HorizontalAlignment="Right" />
                    </Grid>
                </local:FZMaterial>
            </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="LayoutRoot">
			<!-- Background Blur -->
			<Control Style="{StaticResource A_Style_Control_ScreenBackground}" />

            <ContentControl x:Name="BottomBar" Style="{StaticResource A_Style_ButtonBar}">
                <ContentControl x:Name="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}">
                <Grid Style="{StaticResource A_Style_FrameworkElement_ScreenTilt}">
                    <StackPanel Orientation="Vertical" VerticalAlignment="Top" HorizontalAlignment="Center">
                        <StackPanel Orientation="Horizontal" Margin="0,0,0,6" Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                            <ContentControl x:Name="TitleBlock"
                                                Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                                Content="{Binding Title}"
                                                Tag="{Binding Subtitle}"
                                                HorizontalAlignment="Left"
                                                Margin="0,0,0,0" />
                        </StackPanel>

                        <StackPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                                                        Orientation="Horizontal"
                                                        HorizontalAlignment="Center">
                            <StackPanel>
                                <ContentControl Style="{StaticResource A_Style_HeaderRow}" Template="{StaticResource A_ControlTemplate_HeaderRow}" />
                                <Grid>
                                    <Grid Height="624">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="*" />
                                        </Grid.RowDefinitions>
                                        <local:FZMaterial Grid.Column="0" Grid.Row="0" Grid.RowSpan="12" 
                                                              Color="{StaticResource A_Color_Leaderboard_RowBackground}" Preset="{StaticResource A_FZMaterialPresetGlass_Standard}" />
                                        <local:FZMaterial Grid.Column="0" Grid.Row="0" Color="{StaticResource A_Color_DividingLineNoData}" Height="2" VerticalAlignment="Bottom" />
                                        <local:FZMaterial Grid.Column="0" Grid.Row="1" Color="{StaticResource A_Color_DividingLineNoData}" Height="2" VerticalAlignment="Bottom" />
                                        <local:FZMaterial Grid.Column="0" Grid.Row="2" Color="{StaticResource A_Color_DividingLineNoData}" Height="2" VerticalAlignment="Bottom" />
                                        <local:FZMaterial Grid.Column="0" Grid.Row="3" Color="{StaticResource A_Color_DividingLineNoData}" Height="2" VerticalAlignment="Bottom" />
                                        <local:FZMaterial Grid.Column="0" Grid.Row="4" Color="{StaticResource A_Color_DividingLineNoData}" Height="2" VerticalAlignment="Bottom" />
                                        <local:FZMaterial Grid.Column="0" Grid.Row="5" Color="{StaticResource A_Color_DividingLineNoData}" Height="2" VerticalAlignment="Bottom" />
                                        <local:FZMaterial Grid.Column="0" Grid.Row="6" Color="{StaticResource A_Color_DividingLineNoData}" Height="2" VerticalAlignment="Bottom" />
                                        <local:FZMaterial Grid.Column="0" Grid.Row="7" Color="{StaticResource A_Color_DividingLineNoData}" Height="2" VerticalAlignment="Bottom" />
                                        <local:FZMaterial Grid.Column="0" Grid.Row="8" Color="{StaticResource A_Color_DividingLineNoData}" Height="2" VerticalAlignment="Bottom" />
                                        <local:FZMaterial Grid.Column="0" Grid.Row="9" Color="{StaticResource A_Color_DividingLineNoData}" Height="2" VerticalAlignment="Bottom" />
                                        <local:FZMaterial Grid.Column="0" Grid.Row="10" Color="{StaticResource A_Color_DividingLineNoData}" Height="2" VerticalAlignment="Bottom" />
                                        <local:FZMaterial Grid.Column="0" Grid.Row="11" Color="{StaticResource A_Color_DividingLineNoData}" Height="2" VerticalAlignment="Bottom" />
                                    </Grid>
                                    <local:CommonListBox x:Name="PART_ListBox_LeaderboardList" ItemsSource="{Binding LeadersList}" MaxHeight="624" 
                                                        ItemContainerStyle="{StaticResource A_Style_ListBoxItem_DriverList_StartingGrid}"  
                                                        Style="{StaticResource A_Style_CommonListBox_Leaderboard}" 
                                                        VerticalAlignment="Top"
                                                        VirtualizingStackPanel.VirtualizationMode="Recycling" ScrollViewer.CanContentScroll="true"/>

                                </Grid>
                                <Control Style="{StaticResource A_Style_FooterRow}" Template="{StaticResource A_ControlTemplate_FooterRow}" />
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                </Grid>
            </Border>
        </Grid>
    </Border>
</Page>
