<OptionsMenu xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <OptionsMenu.Resources>
        <ResourceDictionary>
            <ColorAlias x:Key="A_Color_Background_NonInteractive" Color="{StaticResource H_Color_Primary_Black}" />
            <Double x:Key="A_Opacity_Background_NonInteractive">0.2</Double>

            <Double x:Key="A_Double_CategoryListItem_Width">364</Double>

            <Style x:Key="A_Style_Background_NonInteractive" 
                TargetType="FZMaterial">
                <Setter Property="Preset" Value="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_OuterAll2px}" />
                <Setter Property="Color" Value="{StaticResource A_Color_Background_NonInteractive}" />
                <Setter Property="Opacity" Value="{StaticResource A_Opacity_Background_NonInteractive}" />
            </Style>

            <Style 
                TargetType="OptionsMenu"
                BasedOn="{StaticResource A_Style_Page_Generic}">
                <Setter Property="SelectCommand" Value="{Binding CategorySelectedCommand, RelativeSource={RelativeSource Self}}"/>
                <Setter Property="SelectCommandText" Value="{Loc HelpButtons.IDS_Select}"/>
                <Style.Triggers>
                    <Trigger Property="OptionsFocus" Value="True">
                        <Setter Property="SelectCommand" Value="{Binding SelectedItem.SelectCommand, ElementName=OptionsList}"/>
                        <Setter Property="SelectCommandText" Value="{Binding SelectedItem.SelectCommandText, ElementName=OptionsList}"/>
                    </Trigger>
                </Style.Triggers>
            </Style>

            <DataTemplate
                x:Key="CategoryItemTemplate">
                <Grid>
                    <FZMaterial x:Name="SelectedItemBackground" Preset="{Roundtangle CornerRadius=2}" Color="{StaticResource H_Color_Primary_Black}" Visibility="Collapsed"/>
                    <DockPanel
                        IsHitTestVisible="False"
                        Margin="13,0,10,0">
                        <FZMaterial 
                            x:Name="Arrow"
                            Data="{StaticResource A_Geometry_SpinnerArrow}"
                            Width="16"
                            Height="12"
                            Color="{Binding Color, ElementName=TextBlock}" 
                            Visibility="Hidden"
                            DockPanel.Dock="Right"
                            HorizontalAlignment="Right"
                            RenderTransformOrigin="0.5,0.5">
                            <FZMaterial.RenderTransform>
                                <RotateTransform Angle="90"/>
                            </FZMaterial.RenderTransform>
                        </FZMaterial>
                        <Decorator 
                            Width="8" 
                            DockPanel.Dock="Right"/>
                        <FZTextBlock
                            x:Name="TextBlock"
                            Margin="0"
                            Text="{Binding Title}"
                            FontFamily="Horizon_A"
                            TextAlignment="Left"
                            HorizontalAlignment="Left"
                            ScreenReader.Event="OnChange"
                            ScreenReader.ControlType="Button"
                            ScreenReader.LineType="SelectedItem"
                            ScreenReader.SelectedNumber="{Binding (ItemsControl.AlternationIndex), FallbackValue=0, RelativeSource={RelativeSource AncestorType={Type ListBoxItem}}, Converter={StaticResource A_IndexToNumberConverter}}"
                            ScreenReader.SelectedCount="{Binding Items.Count, FallbackValue=0, RelativeSource={RelativeSource AncestorType={Type Selector}}}"
                            Style="{StaticResource A_Style_FZTextBlock_OptionText}"
                            CapHeight="19" />
                    </DockPanel>
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger
                        Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType=ListBoxItem}}"
                        Value="True">
                        <Setter
                            TargetName="TextBlock"
                            Property="ScreenReader.Line"
                            Value="{Binding Title, Converter={StaticResource A_Converter_TrimInlineMarkup}}" />
                    </DataTrigger>
                    <DataTrigger
                        Binding="{Binding IsKeyboardFocusWithin, ElementName=VirtualizingWrapPanel}"
                        Value="False">
                        <Setter
                            TargetName="TextBlock"
                            Property="Color"
                            Value="{StaticResource A_Color_OptionsItem_Disabled}" />
                        <Setter
                            TargetName="TextBlock"
                            Property="Opacity"
                            Value="{StaticResource A_Double_OptionsItemOpacity_Disabled}" />
                    </DataTrigger>
                    <DataTrigger
                        Binding="{Binding Current}"
                        Value="True">
                        <Setter
                            TargetName="Arrow"
                            Property="Visibility"
                            Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger
                        Binding="{Binding Active}"
                        Value="True">
                        <Setter
                            TargetName="Arrow"
                            Property="RenderTransform">
                            <Setter.Value>
                                <RotateTransform Angle="-90"/>
                            </Setter.Value>
                        </Setter>
                        <Setter
                            TargetName="TextBlock"
                            Property="Opacity"
                            Value="1" />
                        <Setter
                            TargetName="SelectedItemBackground"
                            Property="Visibility"
                            Value="Visible"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <DataTemplate
                DataType="{Type InputBindingsShortcut}">
                <Grid>
                    <FZTextBlock
                        x:Name="TextBlock"
                        IsHitTestVisible="False"
                        Style="{StaticResource H_Style_Text_ListOptionLabel}"
                        FontFamily="Horizon_B" />
                </Grid>
            </DataTemplate>
            <DataTemplate
                DataType="{Type OptionsMenuLanguageButtonOption}">
                <Grid IsHitTestVisible="False">
                <Decorator ClipToBounds="True" HorizontalAlignment="Left">
                    <FZTextBlock 
                        Style="{StaticResource H_Style_Text_ListOptionLabel}"
                        Text="{Binding Title}"
                        FontFamily="Horizon_B" />
                </Decorator>
                    <Control x:Name="CheckBox" VerticalAlignment="Center" HorizontalAlignment="Right" IsHitTestVisible="False" Style="{StaticResource A_Style_Control_Checkbox_Radio}" Tag="{Binding Current}" />
                </Grid>
            </DataTemplate>

            <DataTemplate
                DataType="{Type InputMappingPresetSpinnerOption}">
                <ContentPresenter Content="{Binding Spinner}"
                    Focusable="True"
                    FocusSelf.WhenTrue="{Binding IsKeyboardFocused, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, FallbackValue=False}"/>
            </DataTemplate>
            <Style
                x:Key="A_Style_Control_EmptyItemStyle"
                TargetType="Control">
                <Setter
                    Property="Focusable"
                    Value="False"/>
                <Setter
                    Property="Template">
                    <Setter.Value>
                        <ControlTemplate
                            TargetType="Control">
                            <FZMaterial
                                Style="{StaticResource A_Style_Background_NonInteractive}"
                                Margin="0,2,0,2" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style
                TargetType="FrameworkElement"
                x:Key="OnTopWhenFocusInside">
                <Style.Triggers>
                    <Trigger
                        Property="IsKeyboardFocusWithin"
                        Value="True">
                        <Setter
                            Property="Panel.ZIndex"
                            Value="1" />
                    </Trigger>
                </Style.Triggers>
            </Style>

            <MappingConverter
                x:Key="A_Converter_CategoryCountToVisibility"
                Default="{x:Static Visibility.Visible}">
                <MappingConverterEntry 
                    Key="1"
                    Value="{x:Static Visibility.Collapsed}" />
            </MappingConverter>

            <Style x:Key="A_Style_Grid_HUDSafeFrameIndicators"
                   TargetType="Grid"
                   BasedOn="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
                <Setter Property="Width"
                        Value="Auto" />
                <Setter Property="Height"
                        Value="Auto" />
                <Setter Property="HorizontalAlignment"
                        Value="Stretch" />
                <Setter Property="VerticalAlignment"
                        Value="Stretch" />
                <Setter Property="Visibility"
                        Value="Hidden" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding SelectedOption.ShowSafeFrame}"
                                 Value="True">
                        <Setter Property="Visibility"
                                Value="Visible" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding OptionsFocus}"
                                 Value="False">
                        <Setter Property="Visibility"
                                Value="Hidden" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZMaterial_HUDSafeFrameIndicator"
                   TargetType="FZMaterial">
                <Setter Property="ImageSource"
                        Value="/ForzaUI;component/Textures/Anthem/Icons/Corner.png" />
                <Setter Property="Width"
                        Value="64" />
                <Setter Property="Height"
                        Value="64" />
                <Setter Property="RenderTransformOrigin"
                        Value="0.5,0.5" />
            </Style>

            <Style x:Key="H_Style_Options_Title"
                TargetType="ContentControl"
                BasedOn="{StaticResource H_Style_TemplatedWrapper_ScreenTitle}">
                <Setter Property="Content" Value="{Binding Title}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Categories.Count}" Value="1">
                        <Setter Property="Content" Value="{Binding SelectedCategory.Title}"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_SidePanel_Options" TargetType="ContentPresenter">
                <Setter Property="Content" Value="{Binding SelectedItem.Description, ElementName=OptionsList}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsEnabled, ElementName=OptionsList}" Value="False">
                        <Setter Property="Content" Value="{Binding SelectedItem.Description, ElementName=CategoryList}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_SidePanelDetails_Options" TargetType="ContentPresenter">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsEnabled, ElementName=OptionsList}" Value="True">
                        <Setter Property="Content" Value="{Binding CurrentCategory.Details}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_ControllerButtonControl_FullscreenPreviewButton" TargetType="ControllerButtonControl" BasedOn="{StaticResource A_Style_ControllerButtonControl_Default}">
                <Setter Property="Button" Value="{Binding Button, ElementName=FullscreenPreviewButtonInput}"/>
                <Setter Property="Description" Value="{Binding SelectedOption.PreviewText, RelativeSource={RelativeSource AncestorType=Page}}"/>
                <Setter Property="Visibility" Value="{Binding Command, Converter={StaticResource A_Converter_VisibleWhenNotNull}, ElementName=FullscreenPreviewButtonInput}"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
                <Setter Property="Margin" Value="0,8"/>
                <Setter Property="HideBackground" Value="True"/>
            </Style>

            <Style x:Key="A_Style_ControllerButtonControl_LivePreviewButton" TargetType="ControllerButtonControl" BasedOn="{StaticResource A_Style_ControllerButtonControl_Default}">
                <Setter Property="Button" Value="{Binding Button, ElementName=PreviewButtonInput}"/>
                <Setter Property="Description" Value ="{Binding SelectedOption.PreviewText}"/>
                <Setter Property="Visibility" Value="{Binding Command, Converter={StaticResource A_Converter_VisibleWhenNotNull}, ElementName=PreviewButtonInput}"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
                <Setter Property="Margin" Value="0,8"/>
                <Setter Property="HideBackground" Value="True"/>
            </Style>

            <DataTemplate DataType="{x:Type OptionsMenuImageOptionPreview}">
                <StackPanel>
                    <ControllerButtonControl Style="{StaticResource A_Style_ControllerButtonControl_FullscreenPreviewButton}"/>
                    <FZMaterial Width="324" Height ="184" Preset="{StaticResource H_Roundtangle_Outer_1px}"> 
                        <FZMaterial Margin="2" ImageSource="{Binding ThumbnailPath}"/> 
                    </FZMaterial>
                </StackPanel>
            </DataTemplate>

            <DataTemplate DataType="{x:Type OptionsMenuVideoOptionPreview}">
                <StackPanel>
                    <ControllerButtonControl Style="{StaticResource A_Style_ControllerButtonControl_FullscreenPreviewButton}"/>
                    <FZMaterial Width="324" Height ="184" Preset="{StaticResource H_Roundtangle_Outer_1px}">
                        <FZMediaElement x:Name="PART_SignLanguage_Video"
                                              Source="{Binding ThumbnailPath}"
                                              FzMediaElementExtension.Loop="True"
                                              LoadedBehavior="Play"
                                              UnloadedBehavior="Close"
                                              Margin="2"
                                              IsMuted="True"
                                              />
                    </FZMaterial>
                </StackPanel>
            </DataTemplate>

            <DataTemplate DataType="{x:Type OptionsMenuMultiOptionPreview}">
                <ContentPresenter Content="{Binding SelectedPreview}"/>
            </DataTemplate>

            <Style x:Key="A_Style_SidePanelPreview_Options" TargetType="ContentPresenter">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsEnabled, ElementName=OptionsList}" Value="True">
                        <Setter Property="Content" Value="{Binding SelectedItem.Preview, ElementName=OptionsList}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_ContentPresenter_PerformancePanelPresenter" TargetType="ContentPresenter">
                <Setter Property="Visibility" Value="Collapsed"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsEnabled, ElementName=OptionsList}" Value="True">
                        <Setter Property="Visibility" Value="{Binding CurrentCategory.ShowsPerformancePanel, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <DataTemplate DataType="{Type OptionsMenuNetworkDiagnosticButtonOption}">
                <Grid IsHitTestVisible="False">
                    <DockPanel>
                        <Decorator MaxWidth="370" HorizontalAlignment="Left">
                            <FZTextBlock 
                                Text="{Binding Title}"
                                Style="{StaticResource H_Style_Text_ListOptionLabelForAutoScroll}"
                                ScreenReader.ControlType="Button"/>
                        </Decorator>
                        <FZMaterial DockPanel.Dock="Right"
                            Margin="12,0"
                            GetSizeFromTexture="True"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Center"
                            ImageSource="/ForzaUI;component/Textures/Data_Bound/ui_symbols/Network_Warning_Breadcrumb.png"
                            Visibility="{Binding ShowWarningIcon, Converter={FZBooleanToVisibilityConverter UseHidden=True}}"/>
                    </DockPanel>
                </Grid>
            </DataTemplate>

            <DataTemplate DataType="{x:Type local:OptionsMenuItemDescriptionNetwork}">
                <DataTemplate.Resources>
                    <Style x:Key="A_Style_FZRun_Description_Markup_HIGHLIGHT" TargetType="local:FZRun">
                        <Setter Property="Color" Value="{StaticResource H_Color_Primary_Green}"/>
                    </Style>
                    
                    <MappingConverter x:Key="A_MappingConverter_Extras" >
                        <MappingConverterEntry Key="{NoCase HIGHLIGHT}" Value="{StaticResource A_Style_FZRun_Description_Markup_HIGHLIGHT}" />
                    </MappingConverter>

                    <MappingConverter x:Key="A_Converter_ServiceStatusBoolToColor">
                        <MappingConverterEntry Key="True"   Value="{StaticResource A_Color_NetworkStatus_Available}"/>
                        <MappingConverterEntry Key="False" Value="{StaticResource A_Color_NetworkStatus_Unavailable}"/>
                    </MappingConverter>

                    <MappingConverter x:Key="A_Converter_ServiceStatusBoolToImageSource">
                        <MappingConverterEntry Key="True"   Value="/ForzaUI;component/Textures/Data_Bound/ui_symbols/Network_Tick.png"/>
                        <MappingConverterEntry Key="False"     Value="/ForzaUI;component/Textures/Data_Bound/ui_symbols/Network_Warning.png"/>
                    </MappingConverter>

                    <MappingConverter x:Key="A_Converter_ServiceStatusBoolToDefaultText">
                        <MappingConverterEntry Key="True"   Value="{Loc Lobby.IDS_NetworkDiagnostics_Status_AllOnline}"/>
                        <MappingConverterEntry Key="False"     Value="{Loc Lobby.IDS_NetworkDiagnostics_Status_NotAllOnline}"/>
                    </MappingConverter>

                    <Style x:Key="A_Style_InfoPanel_Text" TargetType="FZTextBlock" BasedOn="{StaticResource H_Style_Text_Description_Body_16px}">
                        <Setter Property="HorizontalAlignment" Value="Left"/>
                        <Setter Property="TextAlignment" Value="Left"/>
                        <Setter Property="Margin" Value="0,11,0,0"/>
                        <Setter Property="LineAdjust" Value="-0.5" />
                        <Setter Property="MarkupConverter" Value="{StaticResource A_MappingConverter_Extras}"/>
                    </Style>

                    <Style x:Key="A_Style_InfoPanel_Text_Header" TargetType="FZTextBlock" BasedOn="{StaticResource A_Style_InfoPanel_Text}">
                        <Setter Property="Margin" Value="0,23,0,2"/>
                    </Style>

                    <Style x:Key="A_Style_InfoPanel_ServiceStatusText" TargetType="FZTextBlock" BasedOn="{StaticResource H_Style_Text_Description_Body_16px}">
                        <Setter Property="Text" Value="{Binding NetworkFeaturesOnline, Converter={StaticResource A_Converter_ServiceStatusBoolToDefaultText}}"/>
                        <Setter Property="Color" Value="{Binding NetworkFeaturesOnline, Converter={StaticResource A_Converter_ServiceStatusBoolToColor}}"/>
                    </Style>
                </DataTemplate.Resources>
                <Decorator Margin="24">
                    <DockPanel>
                        <StackPanel DockPanel.Dock="Bottom">
                            <ControllerButtonControl Button="A" 
                                                Description="{Loc Lobby.IDS_NetworkDiagnostics_Prompt_Status}" 
                                                HideBackground="True"
                                                AllowMouseClick="False"
                                                Style="{StaticResource A_Style_ControllerButtonControl_Default}" 
                                                Visibility="Visible"
                                                HorizontalAlignment="Center"/>
                        </StackPanel>
                        <StackPanel DockPanel.Dock="Top"  Orientation="Vertical"
                            ScreenReader.Line="{Binding NarratorNetworkStatus, Converter={StaticResource A_Converter_TrimInlineMarkup}}"
                            ScreenReader.LineType="ItemDescription"
                            ScreenReader.Event="OnChange">
                            <FZTextBlock Style="{StaticResource A_Style_InfoPanel_Text}"
                                HorizontalAlignment="Center"
                                TextAlignment="Center"
                                Margin="0,0,0,3"
                                Text="{Loc Lobby.IDS_NetworkDiagnostics_Title}"/>
                            <FZTextBlock Style="{StaticResource A_Style_InfoPanel_Text_Header}"
                                Text="{Loc Lobby.IDS_NetworkDiagnostics_VersionLabel}"/>
                            <FZTextBlock Style="{StaticResource A_Style_InfoPanel_Text}"
                                Text="{Binding Version}"/>
                            <FZTextBlock Style="{StaticResource A_Style_InfoPanel_Text_Header}"
                                Text="{Loc Lobby.IDS_NetworkDiagnostics_OnlineDataVersionLabel}"/>
                            <FZTextBlock Style="{StaticResource A_Style_InfoPanel_Text}"
                                Text="{Binding DataVersion}"/>
                            <FZTextBlock Style="{StaticResource A_Style_InfoPanel_Text_Header}"
                                Text="{Loc Lobby.IDS_NetworkDiagnostics_ServiceConditions}"/>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,20,0,0">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="26"/><!-- so the icon popping in with its GetSizeFromTexture fits in this cell, avoiding the text label moving after 1 frame -->
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <FZMaterial Grid.Column="0" GetSizeFromTexture="True"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Center"
                                        Color="{Binding NetworkFeaturesOnline, Converter={StaticResource A_Converter_ServiceStatusBoolToColor}}"
                                        ImageSource="{Binding NetworkFeaturesOnline, Converter={StaticResource A_Converter_ServiceStatusBoolToImageSource}}"
                                        Visibility="{Binding Downloaded, RelativeSource={RelativeSource Self}, Converter={FZBooleanToVisibilityConverter UseHidden=True}}"/>
                                    <FZTextBlock Grid.Column="1" Style="{StaticResource A_Style_InfoPanel_ServiceStatusText}" Margin="10,4"/>
                                </Grid>
                            </StackPanel>

                            <StackPanel Visibility="{Binding NetworkFeaturesOnline, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                        HorizontalAlignment="Left">
                                <FZTextBlock Style="{StaticResource A_Style_InfoPanel_Text_Header}"
                                    Visibility="{Binding ConnStats, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                    Text="{Loc Lobby.IDS_NetworkDiagnostics_ServerConnStatsLabel}"/>
                                <FZTextBlock Style="{StaticResource A_Style_InfoPanel_Text}"
                                    Visibility="{Binding ConnStats, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                    Text="{Binding ConnStats}"/>
                                <FZTextBlock Style="{StaticResource A_Style_InfoPanel_Text_Header}"
                                    Visibility="{Binding ServerRegion, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                    Text="{Loc Lobby.IDS_NetworkDiagnostics_RegionLabel}"/>
                                <FZTextBlock Style="{StaticResource A_Style_InfoPanel_Text}"
                                    Visibility="{Binding ServerRegion, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                    Text="{Binding ServerRegion}"/>
                                <FZTextBlock Style="{StaticResource A_Style_InfoPanel_Text_Header}"
                                    Visibility="{Binding ServerHostName, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                    Text="{Loc Lobby.IDS_NetworkDiagnostics_HostNameLabel}"/>
                                <FZTextBlock Style="{StaticResource A_Style_InfoPanel_Text}"
                                    Visibility="{Binding ServerHostName, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                    Text="{Binding ServerHostName}"/>
                            </StackPanel>
                        </StackPanel>
                    </DockPanel>
                </Decorator>
            </DataTemplate>

        </ResourceDictionary>
    </OptionsMenu.Resources>
    <UIPageTransitionManager.TransitionManager>
        <UIPageTransitionManager
            Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}" />
    </UIPageTransitionManager.TransitionManager>
    <Grid>
        <PageInputHandler
            x:Name="SelectButtonInput"
            Command="{Binding SelectCommand}"
            Button="A" />
        <PageInputHandler
            x:Name="SaveButtonInput"
            Command="{Binding CurrentCategory.Options.SaveCommand}"
            Button="Start" />
        <PageInputHandler
            x:Name="PreviewButtonInput"
            Button="Back">
            <PageInputHandler.Style>
                <Style TargetType="PageInputHandler">
                    <Setter Property="Command" Value="{Binding SelectedOption.PreviewCommand}"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding OptionsFocus}" Value="False">
                            <Setter Property="Command" Value="{x:Null}"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </PageInputHandler.Style>
        </PageInputHandler>
        <PageInputHandler
            x:Name="FullscreenPreviewButtonInput"
            Button="R3">
            <PageInputHandler.Style>
                <Style TargetType="PageInputHandler">
                    <Setter Property="Command" Value="{Binding SelectedOption.FullscreenPreviewCommand}"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding OptionsFocus}" Value="False">
                            <Setter Property="Command" Value="{x:Null}"/>
                        </DataTrigger>
                        <!-- FallbackValue=True so that if the preview doesn't have the SelectedPreview property we don't affect it-->
                        <DataTrigger Binding="{Binding SelectedOption.Preview.SelectedPreview, Converter={StaticResource A_Converter_TrueIfNotNull}, FallbackValue=True}" Value="False">
                            <Setter Property="Command" Value="{x:Null}"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </PageInputHandler.Style>
        </PageInputHandler>
        <PageInputHandler
            x:Name="ResetDefaultButtonInput"
            Button="Y">
            <PageInputHandler.Style>
                <Style TargetType="PageInputHandler">
                    <Setter Property="Command" Value="{Binding CurrentCategory.Options.ResetToDefaultCommand}"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding OptionsFocus}" Value="False">
                            <Setter Property="Command" Value="{x:Null}"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </PageInputHandler.Style>
        </PageInputHandler>
        <PageInputHandler
            x:Name="ItemXButtonInput"
            Button="X">
            <PageInputHandler.Style>
                <Style TargetType="PageInputHandler">
                    <Setter Property="Command" Value="{Binding ShowAccountPickerPopupCommand}"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding IsPC, Source={StaticResource PART_UISceneContext}}" Value="True" >
                            <Setter Property="Command" Value="{x:Null}"/>
                        </DataTrigger>                        
                        <DataTrigger Binding="{Binding OptionsFocus}" Value="True">
                            <Setter Property="Command" Value="{Binding SelectedItem.AuxCommand, ElementName=OptionsList}"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </PageInputHandler.Style>
        </PageInputHandler>
        <Control
            Style="{StaticResource A_Style_Control_ScreenBackground}" />
        <PlayerBarControl
            x:Name="TopBar"
            Style="{StaticResource A_Style_PlayerBarControl}"
            Visibility="{Binding IsInPauseFlow, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}" />
        <ContentControl
            x:Name="BottomBar"
            Style="{StaticResource A_Style_ButtonBar}">
            <ControllerButtonPanel
                x:Name="PART_HelpPanel"
                Style="{StaticResource A_Style_ControllerButtonPanel_Default}">
                <ControllerButtonControl 
                    Button="{Binding Button, ElementName=SelectButtonInput}"
                    Description="{Binding SelectCommandText}"
                    Visibility="{Binding Command, Converter={StaticResource A_Converter_VisibleWhenNotNull}, ElementName=SelectButtonInput}" />
                <ControllerButtonControl
                    Button="B"
                    Description="{Loc HelpButtons.IDS_Back}" />
                <ControllerButtonControl
                    Button="{Binding Button, ElementName=ResetDefaultButtonInput}"
                    Description="{Loc HelpButtons.IDS_ResetDefault}"
                    Visibility="{Binding Command, Converter={StaticResource A_Converter_VisibleWhenNotNull}, ElementName=ResetDefaultButtonInput}" />
                <ControllerButtonControl
                    Button="{Binding Button, ElementName=SaveButtonInput}"
                    Description="{Loc HelpButtons.IDS_Save}"
                    Visibility="{Binding Command, Converter={StaticResource A_Converter_VisibleWhenNotNull}, ElementName=SaveButtonInput}" />
                <ControllerButtonControl
                    Button="{Binding Button, ElementName=PreviewButtonInput}"
                    Description="{Binding SelectedOption.PreviewText}"
                    Visibility="{Binding Command, Converter={StaticResource A_Converter_VisibleWhenNotNull}, ElementName=PreviewButtonInput}"/>
                <ControllerButtonControl
                    Button="{Binding Button, ElementName=FullscreenPreviewButtonInput}"
                    Description="{Binding SelectedOption.PreviewText}"
                    Visibility="{Binding Command, Converter={StaticResource A_Converter_VisibleWhenNotNull}, ElementName=FullscreenPreviewButtonInput}"/>
                <ControllerButtonControl 
                    Button="{Binding Button, ElementName=ItemXButtonInput}"
                    Description="{Binding Command.Name, ElementName=ItemXButtonInput, FallbackValue={local:Loc HelpButtons.IDS_ChangeUser}}"
                    Visibility="{Binding Command, Converter={StaticResource A_Converter_VisibleWhenNotNull}, ElementName=ItemXButtonInput}"/>
            </ControllerButtonPanel>
        </ContentControl>
        <Border
            Style="{StaticResource A_Style_Border_ScenePadding}"
            SnapsToDevicePixels="True"
            UseLayoutRounding="True">
            <StackPanel
                Orientation="Vertical"
                HorizontalAlignment="Center"
                VerticalAlignment="Center">
                <Decorator
                    Style="{StaticResource A_Style_FrameworkElement_DefaultTransition}"
                    UIPageTransitionManager.TransitionIndex="0">
                    <ContentControl
                        Style="{StaticResource H_Style_Options_Title}"
                        HorizontalAlignment="Left" 
                        Width="{StaticResource A_Double_CategoryListItem_Width}"
                        />
                </Decorator>
                <Decorator
                    Style="{StaticResource A_Style_FrameworkElement_DefaultTransition}"
                    UIPageTransitionManager.TransitionIndex="1"
                    Focusable="False"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Bottom">
                    <DockPanel Height="698">
                        <Decorator
                            x:Name="CategoryDisplayer"
                            Style="{StaticResource OnTopWhenFocusInside}"
                            Visibility="{Binding Categories.Count, Converter={StaticResource A_Converter_CategoryCountToVisibility}}">
                            <WrapListBox
                                IsEnabled="{Binding OptionsFocus, Converter={StaticResource A_Converter_Boolean_Invert}}"
                                x:Name="CategoryList"
                                Width="{StaticResource A_Double_CategoryListItem_Width}"
                                Template="{StaticResource H_ControlTemplate_TextMenu_Default}"
                                ScrollOrientation="Vertical"
                                FocusOnPageFocusGained.SelectorSelectedItem="True"
                                Margin="0"
                                ItemHeight="54"
                                ItemWidth="{StaticResource A_Double_CategoryListItem_Width}"
                                AlternationCount="10000"
                                DockPanel.Dock="Left"
                                ItemsSource="{Binding Categories}"
                                ItemContainerStyle="{StaticResource A_Style_ListBoxItem_TextMenu_Gaps}"
                                EmptyItemStyle="{StaticResource A_Style_Control_EmptyItemStyle}"
                                ItemTemplate="{StaticResource CategoryItemTemplate}" >
                                <WrapListBox.Style>
                                    <Style TargetType="WrapListBox">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding OptionsFocus}" Value="False">
                                                <Setter 
                                                    Property="SelectedItem"
                                                    Value="{Binding SelectedCategory, Mode=TwoWay}"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </WrapListBox.Style>
                            </WrapListBox>
                        </Decorator>
                        <Decorator
                            Width="4"
                            DockPanel.Dock="Left" />

                        <DockPanel DockPanel.Dock="Right">
                            <ContentPresenter DockPanel.Dock="Bottom" Content="{Binding PerformancePanel}" Margin="0,4,0,0" Style="{StaticResource A_Style_ContentPresenter_PerformancePanelPresenter}" Width="364"/>
                            <ContentControl Template="{StaticResource A_ControlTemplate_SidePanel}"
                                            Tag="{local:Loc Assists.IDS_Title_Description}"
                                            VerticalAlignment="Stretch"
                                            Width="364">
                                <DockPanel>
                                    <ControllerButtonControl DockPanel.Dock="Top" Style="{StaticResource A_Style_ControllerButtonControl_LivePreviewButton}" 
                                                             Visibility="{Binding Command, Converter={StaticResource A_Converter_VisibleWhenNotNull}, ElementName=PreviewButtonInput}"/>
                                    <ContentPresenter DockPanel.Dock="Top"
                                        Style="{StaticResource A_Style_SidePanelPreview_Options}"/>
                                    <ContentPresenter DockPanel.Dock="Bottom"
                                        Style="{StaticResource A_Style_SidePanelDetails_Options}"/>
                                    <ContentPresenter Style="{StaticResource A_Style_SidePanel_Options}" IsHitTestVisible="False" Focusable="False"/>
                                </DockPanel>
                            </ContentControl>
                        </DockPanel>
                        <Decorator
                            Width="8"
                            DockPanel.Dock="Right" />
                        <ScrollBar
                            Style="{StaticResource A_Style_ScrollBar_Default}"
                            DockPanel.Dock="Right"
                            Minimum="{Binding ScrollWindowMin, ElementName=OptionsList}"
                            Maximum="{Binding ScrollWindowMax, ElementName=OptionsList}"
                            Value="{Binding ScrollWindowValue, ElementName=OptionsList, Mode=TwoWay}"
                            ViewportSize="{Binding ScrollWindowSize, ElementName=OptionsList}" />
                        <Decorator
                            Width="8"
                            DockPanel.Dock="Right" />
                        <Grid>
                            <WrapListBox
                                IsEnabled="{Binding OptionsFocus}"
                                Width="1000"
                                Template="{StaticResource H_ControlTemplate_TextMenu_Default}"
                                ScrollOrientation="Vertical"
                                x:Name="OptionsList"
                                ItemHeight="54"
                                ItemWidth="1000"
                                FocusOnPageFocusGained.SelectorSelectedItem="True"
                                WrapSelection="True"
                                EnableUnselectableItems="True"
                                AlternationCount="10000"
                                DockPanel.Dock="Left"
                                ItemsSource="{Binding CurrentCategory.Options.OptionsView}"
                                ItemContainerStyle="{StaticResource A_Style_ListBoxItem_TextMenu_OptionsMenuItems}"
                                EmptyItemStyle="{StaticResource A_Style_Control_EmptyItemStyle}" >
                                <WrapListBox.Style>
                                    <Style TargetType="WrapListBox">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding OptionsFocus}" Value="True">
                                                <Setter 
                                                    Property="SelectedItem"
                                                    Value="{Binding SelectedOption, Mode=TwoWay}"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </WrapListBox.Style>
                            </WrapListBox>
                        </Grid>
                    </DockPanel>
                </Decorator>
            </StackPanel>
        </Border>

        <Grid Style="{StaticResource A_Style_Grid_HUDSafeFrameIndicators}"
              Margin="{Binding SafeFrame, Source={x:Static SafeFrameSliderOption.SafeFrame}}">
            <FZMaterial Style="{StaticResource A_Style_FZMaterial_HUDSafeFrameIndicator}"
                              HorizontalAlignment="Left"
                              VerticalAlignment="Top">
                <FZMaterial.RenderTransform>
                    <RotateTransform Angle="90"/>
                </FZMaterial.RenderTransform>
            </FZMaterial>
            <FZMaterial Style="{StaticResource A_Style_FZMaterial_HUDSafeFrameIndicator}"
                              HorizontalAlignment="Left"
                              VerticalAlignment="Bottom" />
            <FZMaterial Style="{StaticResource A_Style_FZMaterial_HUDSafeFrameIndicator}"
                              HorizontalAlignment="Right"
                              VerticalAlignment="Top">
                <FZMaterial.RenderTransform>
                    <RotateTransform Angle="180"/>
                </FZMaterial.RenderTransform>
            </FZMaterial>
            <FZMaterial Style="{StaticResource A_Style_FZMaterial_HUDSafeFrameIndicator}"
                              HorizontalAlignment="Right"
                              VerticalAlignment="Bottom">
                <FZMaterial.RenderTransform>
                    <RotateTransform Angle="270"/>
                </FZMaterial.RenderTransform>
            </FZMaterial>
        </Grid>

        <StackPanel Visibility="Collapsed">
            <FZTextBlock
                CapHeight="20"
                Text="{Binding SelectedIndex, ElementName=CategoryList}" />
            <FZTextBlock
                CapHeight="20"
                Text="{Binding CurrentCategory.Options.IsDirty}" />
            <FZTextBlock
                CapHeight="20"
                Text="{Binding (FocusManager.FocusedElement), RelativeSource={RelativeSource Self}}" />
            <Button
                Content="hi"
                Focusable="True" />
        </StackPanel>
    </Grid>
</OptionsMenu>