<Page
    x:Class="InputPanelSamples.CustomTemplate"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:InputPanelSamples"
    xmlns:c1="using:C1.Xaml"
    xmlns:c1input="using:C1.Xaml.InputPanel"
    xmlns:common="using:InputPanelSamples.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    x:Name="CustomPage"
    mc:Ignorable="d">

    <Page.Resources>
        <common:BooleanToVisibilityConverter x:Key="B2V" />

        <Style TargetType="c1input:C1InputDateTimePicker">
            <Setter Property="EditMode" Value="Date"/>
        </Style>
        
        <DataTemplate x:Key="InputPanelCustomDataTemplate">
            <StackPanel>
                <TextBlock Text="This is from user custom data template." FontWeight="Bold" Margin="2,2,2,5"/>

                <c1input:C1InputTextBox Header="ID" DataBinding="{Binding ID, Mode=OneWay}" IsReadOnly="True" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1input:C1InputTextBox>

                <c1input:C1InputComboBox Header="Country" DataBinding="{Binding Country, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding Countrys, ElementName=CustomPage}"
                                    IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1input:C1InputComboBox>

                <c1input:C1InputTextBox Header="Name" DataBinding="{Binding Name, Mode=OneWay}" IsReadOnly="True" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1input:C1InputTextBox>

                <c1input:C1InputTextBox Header="First Name" DataBinding="{Binding First, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                   IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1input:C1InputTextBox>

                <c1input:C1InputBase Header="Last Name" IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                    <TextBox BorderThickness="3" Text="{Binding Last, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                             IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}">
                    </TextBox>
                </c1input:C1InputBase>

                <c1input:C1InputDateTimePicker Header="Birth Date" DataBinding="{Binding BirthDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" AllowNull="True"
                                    IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1input:C1InputDateTimePicker>

                <c1input:C1InputNumericBox Header="Age" DataBinding="{Binding Age, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                    IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1input:C1InputNumericBox>

                <c1input:C1InputNumericBox Header="Weight" DataBinding="{Binding Weight, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                    IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1input:C1InputNumericBox>

                <c1input:C1InputComboBox Header="Occupation" DataBinding="{Binding Occupation, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding EnumValues, ElementName=CustomPage}"
                                    IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1input:C1InputComboBox>

                <c1input:C1InputMaskedTextBox Header="Phone Number" Mask="(000) 000-0000" DataBinding="{Binding Phone, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                    IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1input:C1InputMaskedTextBox>

                <c1input:C1InputCheckBox Header="Active" DataBinding="{Binding Active, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                    IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1input:C1InputCheckBox>
            </StackPanel>
        </DataTemplate>
        
        <ItemsPanelTemplate x:Key="ItemsPanel">
            <StackPanel Orientation="Vertical" Margin="20" Background="Wheat"/>
        </ItemsPanelTemplate>
    </Page.Resources>
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">            
        <c1input:C1InputPanel x:Name="InputPanel" Grid.Row="1" Margin="15"
                         AutoGenerate="{Binding IsChecked, ElementName=AutoGenerate}"
                         AutoCommit="{Binding IsChecked, ElementName=AutoCommit}"
                         IsReadOnly="{Binding IsChecked, ElementName=IsReadOnly}"
                         DataPagerVisibility="{Binding IsChecked, ElementName=DataPagerVisibility, Converter={StaticResource B2V}}"
                         AddButtonVisibility="{Binding IsChecked, ElementName=AddButtonVisibility, Converter={StaticResource B2V}}"
                         DeleteButtonVisibility="{Binding IsChecked, ElementName=DeleteButtonVisibility, Converter={StaticResource B2V}}"
                         ItemsTemplate="{StaticResource InputPanelCustomDataTemplate}" 
                         ItemsPanelTemplate="{StaticResource ItemsPanel}"
                         HeaderBackground="LightBlue" 
                         HeaderFontSize="14" 
                         HeaderFontWeight="Bold" 
                         >
            <c1input:C1InputPanel.HeaderTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="Custom Header Template" Margin="6" Foreground="DarkViolet" />
                    </StackPanel>
                </DataTemplate>
            </c1input:C1InputPanel.HeaderTemplate>
        </c1input:C1InputPanel>
    </Grid>
    <Page.BottomAppBar>
        <AppBar HorizontalAlignment="Left">
            <c1:C1WrapPanel Orientation="Horizontal" Margin="10" AllowDrop="True" >
                <CheckBox x:Name="AutoGenerate" Content="AutoGenerate" IsChecked="False" Margin="3" />
                <CheckBox x:Name="AutoCommit" Content="AutoCommit" IsChecked="True" Margin="3" />
                <CheckBox x:Name="IsReadOnly" Content="IsReadOnly" IsChecked="False" Margin="3" />
                <CheckBox x:Name="DataPagerVisibility" Content="DataPagerVisible" IsChecked="True" Margin="3"></CheckBox>
                <CheckBox x:Name="AddButtonVisibility" Content="AddButtonVisible" IsChecked="True" Margin="3"></CheckBox>
                <CheckBox x:Name="DeleteButtonVisibility" Content="DeleteButtonVisible" IsChecked="True" Margin="3"></CheckBox>
            </c1:C1WrapPanel>
        </AppBar> 
    </Page.BottomAppBar>
</Page>
