<?xml version="1.0" encoding="utf-8"?>
<Page
    x:Class="was.droidtransfer.features.contacts.io.controls.ContactsBackupRestoreSelectionPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:was.droidtransfer.features.contacts.io.controls"
    xmlns:androidcontacts="using:was.std.android.contacts.data"
    xmlns:converters="using:was.droidtransfer.features.contacts.converters"
    xmlns:commonconverters="using:was.droidtransfer.features.converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.Resources>
        <converters:ContactGroupToTitleStringConverter x:Key="ContactGroupToTitleStringConverter" />
        <commonconverters:ListCountToVisibilityConverter x:Key="ListCountToVisibilityConverter" />
    </Page.Resources>

    <ScrollView>
        <StackPanel VerticalAlignment="Center" MaxWidth="600" Margin="10,20">
            <TextBlock x:Name="textBlockTitle" Style="{ThemeResource BodyStrongTextBlockStyle}" />
            <TextBlock x:Name="textBlockDescription" Style="{ThemeResource BodyTextBlockStyle}" />
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <StackPanel Margin="0,5,0,0">
                    <RadioButtons x:Name="radioButtonsSelectionType" SelectedIndex="0" SelectionChanged="_radioButtonsSelectionType_SelectionChanged">
                        <RadioButton x:Name="radioButtonAll" Margin="0,-5">
                            <TextBlock x:Name="textBlockAllContacts" />
                        </RadioButton>
                        <RadioButton x:Name="radioButtonSelect" Margin="0,-5">
                            <TextBlock x:Name="textBlockSelectedContacts" />
                        </RadioButton>
                    </RadioButtons>
                </StackPanel>
                <StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Bottom" Spacing="5">
                    <Button>
                        <FontIcon Glyph="&#xEF58;" FontSize="20" Foreground="{ThemeResource TextBoxForegroundThemeBrush}" />
                        <Button.Flyout>
                            <MenuFlyout Placement="Bottom">
                                <RadioMenuFlyoutItem x:Name="menuFlyoutSortByFirst" x:Uid="menuFlyoutSortByFirst" Text="XX Sort by First Name" Click="_menuFlyoutSortByFirst_Click" />
                                <RadioMenuFlyoutItem x:Name="menuFlyoutSortByLast" x:Uid="menuFlyoutSortByLast" Text="XX Sort by Last Name" Click="_menuFlyoutSortByLast_Click" />
                            </MenuFlyout>
                        </Button.Flyout>
                    </Button>
                    <TextBox x:Name="textBoxFilter" x:Uid="textBoxFilter" PlaceholderText="XX Search Contacts" MinWidth="200" TextChanged="_textBoxFilter_TextChanged" />
                </StackPanel>
            </Grid>
            <Border BorderThickness="1" BorderBrush="{ThemeResource ListBoxBorderThemeBrush}" Margin="0,10,0,10">
                <StackPanel>
                    <ComboBox x:Name="comboBoxContactGroups" HorizontalAlignment="Stretch" IsEnabled="False" Visibility="{Binding ItemsSource, ElementName=comboBoxContactGroups, Converter={StaticResource ListCountToVisibilityConverter}, ConverterParameter='2', Mode=OneWay}" CornerRadius="0" BorderThickness="0,0,0,1" SelectionChanged="_comboBoxContactGroups_SelectionChanged">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Converter={StaticResource ContactGroupToTitleStringConverter}}" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
                    <ListView x:Name="listViewContacts" Height="280" SelectionMode="Multiple" IsEnabled="False" SelectionChanged="_listViewContacts_SelectionChanged">
                        <ListView.ItemTemplate>
                            <DataTemplate x:DataType="androidcontacts:VCardContent">
                                <StackPanel Orientation="Horizontal" Spacing="8">
                                    <SymbolIcon Symbol="Contact" Margin="3,0,0,0" />
                                    <TextBlock Text="{x:Bind DisplayName}" />
                                </StackPanel>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                        <ListView.ContextFlyout>
                            <MenuFlyout>
                                <MenuFlyoutItem x:Uid="menuFlyoutItemSelectAll" Text="XX Select All" Click="_menuFlyoutItem_SelectAll" />
                                <MenuFlyoutItem x:Uid="menuFlyoutItemClearSelection" Text="XX Clear Selection" Click="_menuFloutItem_ClearSelection" />
                            </MenuFlyout>
                        </ListView.ContextFlyout>
                    </ListView>
                </StackPanel>
            </Border>
            <Grid ColumnSpacing="10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Button x:Name="buttonBack" x:Uid="buttonBack" Content="XX Back" Click="_buttonBack_Click" />
                <Button x:Name="buttonConfirm" Grid.Column="1" IsEnabled="{x:Bind HasValidSelection, Mode=OneWay}" Click="_buttonConfirm_Click">
                    <TextBlock x:Name="textBlockConfirmContacts" />
                </Button>
            </Grid>
        </StackPanel>
    </ScrollView>
</Page>
