<Page
    x:Class="GolfComp.Views.TeamListPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:GolfComp.Views"
    xmlns:source="using:DataAccessLibrary.Models"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" 
    xmlns:telerikGrid="using:Telerik.UI.Xaml.Controls.Grid"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Page.Resources>
        <source:KlasseModel x:Key="Items"/>
    </Page.Resources>

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <RelativePanel>
            <CommandBar x:Name="mainCommandBar" HorizontalAlignment="Stretch" IsEnabled="{x:Bind enableCommandBar}">
                <AppBarButton
                    Click="Insert_new_entry"
                    Icon="Add"
                    Label="New"
                    ToolTipService.ToolTip="New record"/>
                <AppBarButton
                    Click="Delete_Click"
                    Icon="Delete"
                    Label="Delete"
                    ToolTipService.ToolTip="Delete record" />
                <AppBarButton
                    Click="UpdateRecord_Click"
                    Icon="Refresh"
                    Label="Update"
                    ToolTipService.ToolTip="Update record" />
            </CommandBar>
            <StackPanel
                x:Name="newRecordStackPanel"
                Orientation="Horizontal"                
                RelativePanel.Below="mainCommandBar">
                <ComboBox x:Name="golfclubDropDown" Header="Homeclub" Margin="8,8,16,8" MinWidth="150"/>
                <ComboBox x:Name="klasseDropDown" Header="Competitie" Margin="8,8,16,8" MinWidth="150"/>
                <TextBox
                    x:Name="TeamNaamTextBox"
                    Header="Teamnaam"
                    PlaceholderText="teamnaam"
                    Margin="8,8,16,8"/>
                <AppBarButton x:Name="DeleteNewRecord" Click="DeleteNewRecord_Click" Icon="Cancel"/>
                <AppBarButton x:Name="SaveNewRecord" Click="SaveNewRecord_Click" Icon="Save"/>
            </StackPanel>
            <telerikGrid:RadDataGrid 
                AutoGenerateColumns="False"
                x:Name="Datagrid" 
                BorderThickness="0" 
                ColumnDataOperationsMode="Flyout" 
                GridLinesVisibility="None"
                GroupPanelPosition="Left" 
                RelativePanel.AlignLeftWithPanel="True"
                RelativePanel.AlignRightWithPanel="True"
                RelativePanel.Below="newRecordStackPanel"
                UserEditMode="Inline"
                SelectedItem="{x:Bind SelectedItem, Mode=TwoWay}">
                <telerikGrid:RadDataGrid.Columns>
                    <telerikGrid:DataGridComboBoxColumn PropertyName="Competitie" 
                                                        Header="Competitie"                                                         
                                                        ItemsSource="{x:Bind klasse}"
                                                        DisplayMemberPath="Competitie"
                                                        SelectedValuePath="Klasse_Id" 
                                                        />

                    <telerikGrid:DataGridNumericalColumn PropertyName="Speler1Id" Header="Speler 1"/>
                    <telerikGrid:DataGridNumericalColumn PropertyName="Speler2Id" Header="Speler 2"/>
                    <telerikGrid:DataGridNumericalColumn PropertyName="Speler3Id" Header="Speler 3" />
                    <telerikGrid:DataGridNumericalColumn PropertyName="Speler4Id" Header="Speler 4" />
                    <telerikGrid:DataGridNumericalColumn PropertyName="Speler5Id" Header="Speler 5" />
                    <telerikGrid:DataGridNumericalColumn PropertyName="Speler6Id" Header="Speler 6" />
                    <telerikGrid:DataGridTextColumn PropertyName="Naam" Header="Teamnaam" />
                </telerikGrid:RadDataGrid.Columns>
            </telerikGrid:RadDataGrid>
        </RelativePanel>
    </Grid>

</Page>
