<UserControl
    x:Class="ModernWpf.SampleApp.NavigationRootPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ui="http://schemas.modernwpf.com/2019"
    xmlns:common="clr-namespace:ModernWpf.SampleApp.Common"
    xmlns:local="clr-namespace:ModernWpf.SampleApp"
    xmlns:sc="clr-namespace:SamplesCommon;assembly=SamplesCommon"
    mc:Ignorable="d"
    d:DesignWidth="1200"
    d:DesignHeight="900"
    Background="{DynamicResource SystemControlPageBackgroundAltHighBrush}">

    <UserControl.Resources>
        <common:EqualsConverter
            x:Key="IsDefaultConverter"
            Value="{x:Null}" />
        <common:EqualsConverter
            x:Key="IsLightConverter"
            Value="{x:Static ui:ApplicationTheme.Light}" />
        <common:EqualsConverter
            x:Key="IsDarkConverter"
            Value="{x:Static ui:ApplicationTheme.Dark}" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Grid Grid.ColumnSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Menu>
                <MenuItem Header="Theme">
                    <ui:RadioMenuItem
                        Header="Default"
                        IsChecked="{Binding ApplicationTheme, Source={x:Static sc:ThemeManagerProxy.Current}, Mode=OneWay, Converter={StaticResource IsDefaultConverter}}"
                        Checked="Default_Checked" />
                    <ui:RadioMenuItem
                        Header="Light"
                        IsChecked="{Binding ApplicationTheme, Source={x:Static sc:ThemeManagerProxy.Current}, Mode=OneWay, Converter={StaticResource IsLightConverter}}"
                        Checked="Light_Checked" />
                    <ui:RadioMenuItem
                        Header="Dark"
                        IsChecked="{Binding ApplicationTheme, Source={x:Static sc:ThemeManagerProxy.Current}, Mode=OneWay, Converter={StaticResource IsDarkConverter}}"
                        Checked="Dark_Checked" />
                </MenuItem>
                <MenuItem
                    x:Name="PresetsMenu"
                    Header="Presets"
                    MenuItem.Click="PresetMenuItem_Click">
                    <ui:RadioMenuItem
                        Header="Default"
                        IsChecked="True" />
                    <ui:RadioMenuItem Header="Forest" />
                    <ui:RadioMenuItem Header="Lavender" />
                    <ui:RadioMenuItem Header="Nighttime" />
                </MenuItem>
                <MenuItem
                    Header="Sizing"
                    MenuItem.Click="SizingMenuItem_Click">
                    <ui:RadioMenuItem
                        Header="Standard"
                        IsChecked="True" />
                    <ui:RadioMenuItem
                        Header="Compact"
                        Tag="Compact" />
                </MenuItem>
                <MenuItem
                    Header="Title Bar"
                    DataContext="{Binding RelativeSource={RelativeSource AncestorType=Window}}">
                    <MenuItem
                        Header="IsBackButtonVisible"
                        IsEnabled="False"
                        IsCheckable="True"
                        IsChecked="{Binding Path=(ui:TitleBar.IsBackButtonVisible), Mode=OneWay}" />
                    <MenuItem
                        Header="IsIconVisible"
                        IsCheckable="True"
                        IsChecked="{Binding Path=(ui:TitleBar.IsIconVisible)}" />
                </MenuItem>
                <MenuItem Header="Shadows">
                    <ui:RadioMenuItem
                        x:Name="ShadowsAuto"
                        Header="Use system setting"
                        IsChecked="True"
                        Checked="ShadowsAuto_Checked" />
                    <ui:RadioMenuItem
                        x:Name="ShadowsEnabled"
                        Header="Enabled"
                        Checked="ShadowsEnabled_Checked" />
                    <ui:RadioMenuItem
                        x:Name="ShadowsDisabled"
                        Header="Disabled"
                        Checked="ShadowsDisabled_Checked" />
                </MenuItem>
                <MenuItem Header="Settings">
                    <MenuItem Header="Automatically hide scroll bars">
                        <ui:RadioMenuItem
                            x:Name="AutoHideScrollBarsAuto"
                            Header="Use system setting"
                            IsChecked="True"
                            Checked="AutoHideScrollBarsAuto_Checked" />
                        <ui:RadioMenuItem
                            x:Name="AutoHideScrollBarsOn"
                            Header="On"
                            Checked="AutoHideScrollBarsOn_Checked" />
                        <ui:RadioMenuItem
                            x:Name="AutoHideScrollBarsOff"
                            Header="Off"
                            Checked="AutoHideScrollBarsOff_Checked" />
                    </MenuItem>
                </MenuItem>
                <MenuItem
                    x:Name="DebugMenuItem"
                    Header="Debug"
                    Visibility="Collapsed">
                    <MenuItem
                        Header="Force GC"
                        Click="ForceGC" />
                    <MenuItem
                        x:Name="NewWindowMenuItem"
                        Header="New window"
                        Visibility="Collapsed"
                        Click="NewWindow" />
                </MenuItem>
            </Menu>

            <ui:CommandBar
                x:Name="TopCommandBar"
                Grid.Column="1"
                Margin="0,0,12,0"
                Background="Transparent"
                DefaultLabelPosition="Right">
                <ui:AppBarButton x:Name="ThemeButton" Click="OnThemeButtonClick" Label="Toggle Theme">
                    <ui:AppBarButton.Icon>
                        <ui:FontIcon
                            Glyph="&#xE771;"
                            Margin="0,-2,0,0" />
                    </ui:AppBarButton.Icon>
                </ui:AppBarButton>
            </ui:CommandBar>
        </Grid>

        <DockPanel
            Grid.Row="1"
            Background="{DynamicResource NavigationViewExpandedPaneBackground}">
            <ui:AutoSuggestBox
                x:Name="controlsSearchBox"
                DockPanel.Dock="Top"
                Margin="12"
                PlaceholderText="Search"
                QueryIcon="Find"
                QuerySubmitted="OnControlsSearchBoxQuerySubmitted"
                TextChanged="OnControlsSearchBoxTextChanged" />

            <ui:ListView
                x:Name="PagesList"
                DockPanel.Dock="Top"
                DisplayMemberPath="Title"
                SelectedValuePath="PageType"
                SelectedIndex="0"
                SelectionChanged="PagesList_SelectionChanged">
                <ui:ListView.ItemsSource>
                    <local:ControlPagesData />
                </ui:ListView.ItemsSource>
            </ui:ListView>
        </DockPanel>

        <sc:SampleFrame
            x:Name="rootFrame"
            Grid.Row="1"
            Grid.Column="1"
            Navigating="RootFrame_Navigating"
            Navigated="RootFrame_Navigated" />
    </Grid>
</UserControl>
