<Window
    x:Name="Window"
    x:Class="MahAppsSample.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ui="http://schemas.modernwpf.com/2019"
    xmlns:samplepages="clr-namespace:SamplesCommon.SamplePages;assembly=SamplesCommon"
    xmlns:controlpages="clr-namespace:MahAppsSample.ControlPages"
    mc:Ignorable="d"
    Title="MahApps.Metro Integration"
    Width="1366"
    Height="768"
    MinWidth="500"
    MinHeight="500"
    WindowStartupLocation="CenterScreen"
    ui:WindowHelper.UseModernWindowStyle="True"
    ui:TitleBar.ExtendViewIntoTitleBar="True">

    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

        <DataTemplate x:Key="NavigationViewHeaderTemplate">
            <TextBlock Text="{Binding}" Margin="12,32,0,0" />
        </DataTemplate>
    </Window.Resources>

    <Grid>
        <Grid
            x:Name="AppTitleBar"
            VerticalAlignment="Top"
            Height="{Binding ElementName=NavView, Path=CompactPaneLength}"
            Canvas.ZIndex="1"
            Visibility="{Binding ElementName=Window, Path=(ui:TitleBar.ExtendViewIntoTitleBar), Converter={StaticResource BooleanToVisibilityConverter}}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" MinWidth="{Binding ElementName=Window, Path=(ui:TitleBar.SystemOverlayRightInset)}" />
            </Grid.ColumnDefinitions>
            <TextBlock
                x:Name="AppTitle"
                Text="{Binding ElementName=Window, Path=Title}"
                VerticalAlignment="Center"
                Style="{StaticResource CaptionTextBlockStyle}" />
        </Grid>

        <ui:NavigationView
            x:Name="NavView"
            AlwaysShowHeader="True"
            Header="{Binding SelectedItem.Content, RelativeSource={RelativeSource Self}, FallbackValue=' '}"
            HeaderTemplate="{StaticResource NavigationViewHeaderTemplate}"
            IsBackButtonVisible="Visible"
            IsTitleBarAutoPaddingEnabled="False"
            IsPaneOpen="True"
            OpenPaneLength="240"
            IsBackEnabled="{Binding ElementName=ContentFrame, Path=CanGoBack}"
            BackRequested="NavView_BackRequested"
            ItemInvoked="NavView_ItemInvoked"
            PaneOpening="NavView_PaneOpening"
            PaneClosing="NavView_PaneClosing"
            DisplayModeChanged="NavView_DisplayModeChanged">
            <ui:NavigationView.AutoSuggestBox>
                <ui:AutoSuggestBox PlaceholderText="Hint text" QueryIcon="Find" />
            </ui:NavigationView.AutoSuggestBox>

            <ui:NavigationView.MenuItems>
                <ui:NavigationViewItemHeader Content="Controls" />

                <ui:NavigationViewItem Content="Overview" Tag="{x:Type controlpages:ControlsPage}">
                    <ui:NavigationViewItem.Icon>
                        <ui:FontIcon Glyph="&#xE71D;" />
                    </ui:NavigationViewItem.Icon>
                </ui:NavigationViewItem>

                <ui:NavigationViewItem Content="Theme" Tag="{x:Type controlpages:ThemePage}">
                    <ui:NavigationViewItem.Icon>
                        <ui:FontIcon Glyph="&#xE790;" />
                    </ui:NavigationViewItem.Icon>
                </ui:NavigationViewItem>

                <ui:NavigationViewItem Content="FlipView" Tag="{x:Type controlpages:FlipViewPage}">
                    <ui:NavigationViewItem.Icon>
                        <ui:BitmapIcon UriSource="/Assets/FlipView.png" ShowAsMonochrome="False" />
                    </ui:NavigationViewItem.Icon>
                </ui:NavigationViewItem>

                <ui:NavigationViewItem Content="SimpleTimePicker" Tag="{x:Type controlpages:SimpleTimePickerPage}">
                    <ui:NavigationViewItem.Icon>
                        <ui:BitmapIcon UriSource="/Assets/TimePicker.png" ShowAsMonochrome="False" />
                    </ui:NavigationViewItem.Icon>
                </ui:NavigationViewItem>

                <ui:NavigationViewItemHeader Content="Sample Pages" />
                <ui:NavigationViewItem Content="Sample Page 1" Tag="{x:Type samplepages:SamplePage1}" Icon="Home"/>
                <ui:NavigationViewItem Content="Sample Page 2" Tag="{x:Type samplepages:SamplePage2}" Icon="Keyboard"/>
                <ui:NavigationViewItem Content="Sample Page 3" Tag="{x:Type samplepages:SamplePage3}" Icon="Library"/>
                <ui:NavigationViewItem Content="Sample Page 4" Tag="{x:Type samplepages:SamplePage4}" Icon="Mail"/>
            </ui:NavigationView.MenuItems>

            <ui:Frame x:Name="ContentFrame" Navigated="ContentFrame_Navigated" />
        </ui:NavigationView>
    </Grid>
</Window>
