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

    <Page.Resources>
        <ResourceDictionary>

            <Style x:Key="A_Style_ListBoxItem_CarFilterItem" BasedOn="{StaticResource A_Style_ListBoxItem_TextMenu_Default}" TargetType="ListBoxItem">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsToggle}" Value="False">
                        <Setter Property="Focusable"
                                Value="False" />
                        <Setter Property="Tag"
                                Value="GroupHeader" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <DataTemplate x:Key="A_DataTemplate_ListBoxItem_CarFilterItem">
                <Grid IsHitTestVisible="False"
                      Height="{StaticResource A_Double_TextMenu_Height_Default}">
                    <local:FZTextBlock x:Name="Text" Text="{Binding Text, Converter={StaticResource A_StringToUpper}}" Style="{StaticResource A_Style_FZTextBlock_OptionText}" />
                    <StackPanel HorizontalAlignment="Right" Visibility="{Binding IsToggle, Converter={StaticResource A_Converter_BoolToVis}}" Orientation="Horizontal">
                        <Control x:Name="CheckBox" VerticalAlignment="Center" Style="{StaticResource A_Style_Control_Checkbox}" Tag="{Binding Value}" />
                    </StackPanel>
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Focusable, RelativeSource={RelativeSource TemplatedParent}}"
                             Value="False">
                    </DataTrigger>
                    <DataTrigger Binding="{Binding IsToggle}"
                             Value="False">
                        <Setter TargetName="Text"
                                Property="TextAlignment"
                                Value="Center" />
                        <Setter TargetName="Text"
                                Property="FontFamily"
                                Value="Horizon_C" />
                        <Setter TargetName="Text"
                                Property="Color"
                                Value="{StaticResource A_Color_TextMenu_Text_Highlighted}" />
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <ControlTemplate TargetType="{x:Type ListBox}"
                  x:Key="A_Template_ListBox_FilterPopup">
                <Border Background="{x:Null}">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="ValidationStates">
                            <VisualState x:Name="Valid" />
                            <VisualState x:Name="InvalidFocused" />
                            <VisualState x:Name="InvalidUnfocused" />
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <local:FZScrollViewer Template="{StaticResource A_ControlTemplate_ScrollViewer_Popup_ExternalRightPosition}"
                                          CanContentScroll="True"
                                          Margin="-18,0"
                                          HorizontalScrollBarVisibility="Disabled"
                                          VerticalScrollBarVisibility="{Binding Path=(ScrollViewer.VerticalScrollBarVisibility), RelativeSource={RelativeSource TemplatedParent}}"
                                          local:FZScrollViewer.IsAtTop="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(local:FZScrollViewer.IsAtTop), Mode=OneWayToSource}"
                                          local:FZScrollViewer.IsAtBottom="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(local:FZScrollViewer.IsAtBottom), Mode=OneWayToSource}"
                                          Focusable="False"
                                          KeepSelectionOnScreen="True">
                        <VirtualizingStackPanel Orientation="Vertical"
                                                Margin="18,0"
                                                IsItemsHost="True"
                                                VirtualizingStackPanel.VirtualizationMode="Recycling"
                                                Focusable="False" />
                    </local:FZScrollViewer>
                </Border>
            </ControlTemplate>
        </ResourceDictionary>
    </Page.Resources>

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

    <Grid>
        <Grid>
          <!-- Background Blur -->
          <local:FZMaterialGlassCapture />
          <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Popup_Background}" 
                            MinWidth="{Binding ActualWidth, ElementName=MainContent}"
                            MinHeight="{Binding ActualHeight, ElementName=MainContent}" />

			<!-- Help Button Bar -->
            <ContentControl x:Name="BottomBar"
                            Style="{StaticResource A_Style_ButtonBar}">
                <ContentControl x:Name="DefaultHelpPanel"
                                local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Toggle}"
                                local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                                local:ControllerButtonPanel.XDescription="{local:Loc HelpButtons.IDS_ClearAll}"
                                Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
            </ContentControl>
        </Grid>

        <Grid Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}"
              Focusable="False">
            <StackPanel x:Name="MainContent"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Width="600"
                        Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                
                <ContentControl Content="{Binding Title, Converter={StaticResource A_StringToUpper}}"
                        Style="{StaticResource A_Style_ContentControl_PopupTitleBlock}"/>

                <ContentControl Style="{StaticResource A_Style_ContentControl_PopupContentBlock}"
                                Tag="/ForzaUI;component/Textures/Anthem/Icons/Titles/PopupSettings.png">
                    <local:CommonListBox x:Name="Menu"
                                         Style="{StaticResource A_Style_ListBox_TextMenu_Default}"
                                         ItemContainerStyle="{StaticResource A_Style_ListBoxItem_CarFilterItem}"
                                         ItemTemplate="{StaticResource A_DataTemplate_ListBoxItem_CarFilterItem}"
                                         ItemsSource="{Binding Collection}"
                                         MaxHeight="663"
                                         Template="{StaticResource A_Template_ListBox_FilterPopup}"
                                         SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}">
                    </local:CommonListBox>
                </ContentControl>
            </StackPanel>
        </Grid>
    </Grid>
</Page>
