<Page
    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:viewModels="using:ModernKeePass.ViewModels" 
    xmlns:controls="using:ModernKeePass.Controls"
    x:Class="ModernKeePass.MainPage"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" >
    <Page.DataContext>
        <viewModels:MainVm />
    </Page.DataContext>
    <Page.Resources>
        <CollectionViewSource 
            x:Name="MenuItemsSource" 
            Source="{Binding MainMenuItems}" IsSourceGrouped="True" />
    </Page.Resources>

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="50" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <controls:ListViewWithDisable Grid.Column="0" 
                  x:Name="MenuListView"
                  SelectionChanged="ListView_SelectionChanged" 
                  ItemsSource="{Binding Source={StaticResource MenuItemsSource}}"
                  IsSynchronizedWithCurrentItem="False">
            <ListView.Header>
                <TextBlock Text="ModernKeePass" FontWeight="Bold" FontSize="36" Margin="20" />
            </ListView.Header>
            <ListView.ItemTemplate>
                <DataTemplate >
                    <StackPanel Orientation="Horizontal">
                        <SymbolIcon Symbol="{Binding SymbolIcon}" />
                        <TextBlock Text="{Binding Title}" Margin="10,5,0,0" />
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="Padding" Value="20,5,0,0" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.GroupStyle>
                <GroupStyle HidesIfEmpty="True">
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <Grid Background="DarkGray" Margin="20,0,0,0">
                                <Border Height="1" Width="240" HorizontalAlignment="Stretch"/>
                            </Grid>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ListView.GroupStyle>
        </controls:ListViewWithDisable>
        <Frame Grid.Column="2" Name="MenuFrame" Width="auto" Margin="0,60,0,0" />
    </Grid>
</Page>
