<Page
    x:Class="NixExampleWinUI.Views.ShellPage"
    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:helpers="using:NixExampleWinUI.Helpers"
    xmlns:behaviors="using:NixExampleWinUI.Behaviors"
    xmlns:i="using:Microsoft.Xaml.Interactivity"
    Loaded="OnLoaded">

    <Grid>
        <Grid x:Name="AppTitleBar"
              Canvas.ZIndex="1"
              Height="{Binding ElementName=NavigationViewControl, Path=CompactPaneLength}"
              IsHitTestVisible="True"
              VerticalAlignment="Top">
            <Image Source="/Assets/WindowIcon.ico"
                   HorizontalAlignment="Left"
                   Width="16"
                   Height="16" />
            <TextBlock x:Name="AppTitleBarText"
                       VerticalAlignment="Center"
                       TextWrapping="NoWrap"
                       Style="{StaticResource CaptionTextBlockStyle}"
                       Margin="28,0,0,0"/>
        </Grid>
        <NavigationView
            x:Name="NavigationViewControl"
            Canvas.ZIndex="0"
            IsBackButtonVisible="Visible"
            IsPaneOpen="False"
            IsBackEnabled="{x:Bind ViewModel.IsBackEnabled, Mode=OneWay}"
            SelectedItem="{x:Bind ViewModel.Selected, Mode=OneWay}"
            IsSettingsVisible="True"
            ExpandedModeThresholdWidth="1280"            
            DisplayModeChanged="NavigationViewControl_DisplayModeChanged"
            Header="{x:Bind ((ContentControl)ViewModel.Selected).Content, Mode=OneWay}">
            <NavigationView.MenuItems>
                <!--
                TODO: Update item titles by updating <x:Uid>.Content entries in Strings/en-us/Resources.resw.
                https://docs.microsoft.com/windows/uwp/app-resources/localize-strings-ui-manifest#refer-to-a-string-resource-identifier-from-xaml
            
                TODO: Update item icons by updating FontIcon.Glyph properties.
                https://docs.microsoft.com/windows/apps/design/style/segoe-fluent-icons-font#icon-list
                -->
                <NavigationViewItem x:Uid="Shell_Main" helpers:NavigationHelper.NavigateTo="NixExampleWinUI.ViewModels.MainViewModel">
                    <NavigationViewItem.Icon>
                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe80f;"/>
                    </NavigationViewItem.Icon>
                </NavigationViewItem>
            </NavigationView.MenuItems>
            <NavigationView.HeaderTemplate>
                <DataTemplate>
                    <Grid>
                        <TextBlock
                            Text="{Binding}"
                            Style="{ThemeResource TitleTextBlockStyle}" />
                    </Grid>
                </DataTemplate>
            </NavigationView.HeaderTemplate>
            <i:Interaction.Behaviors>
                <behaviors:NavigationViewHeaderBehavior
                    DefaultHeader="{x:Bind ((ContentControl)ViewModel.Selected).Content, Mode=OneWay}">
                    <behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock
                                    Text="{Binding}"
                                    Style="{ThemeResource TitleTextBlockStyle}" />
                            </Grid>
                        </DataTemplate>
                    </behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
                </behaviors:NavigationViewHeaderBehavior>
            </i:Interaction.Behaviors>
            <Grid Margin="{StaticResource NavigationViewPageContentMargin}">
                <Frame x:Name="NavigationFrame" />
            </Grid>
        </NavigationView>
    </Grid>
</Page>
