<UserControl x:Class="InputPanelSample.CustomTemplate"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" 
             xmlns:System="clr-namespace:System;assembly=mscorlib"
             xmlns:local="clr-namespace:InputPanelSample"
             mc:Ignorable="d" 
             d:DesignHeight="500" d:DesignWidth="500">
    <UserControl.Resources>
        <ObjectDataProvider x:Key="EnumValues" MethodName="GetValues" ObjectType="{x:Type System:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="local:Occupation"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>

        <BooleanToVisibilityConverter x:Key="B2V" />

        <Style x:Key="TextBoxStyle" TargetType="TextBox">
            <Style.Triggers>
                <Trigger Property="IsReadOnly" Value="true">
                    <Setter Property="Background" Value="#FFF4F4F4"/>
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="FootBorder" TargetType="Border">
            <Setter Property="Background" Value="White" />
        </Style>
        <DataTemplate x:Key="InputPanelCustomDataTemplate">
            <StackPanel Width="{TemplateBinding Width}">
                <TextBlock Text="This is from user custom data template." Background="Beige" FontWeight="Bold" />

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

                <c1:C1InputComboBox Header="Country" DataBinding="{Binding Country, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}" ItemsSource="{Binding Countries, RelativeSource={RelativeSource AncestorType=local:CustomTemplate}}"
                                    IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1:C1InputComboBox>

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

                <c1:C1InputTextBox Header="First Name" DataBinding="{Binding First, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}"
                                   IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1:C1InputTextBox>

                <c1:C1InputBase Header="Last Name" IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                    <TextBox Style="{StaticResource TextBoxStyle}" BorderThickness="3" Text="{Binding Last, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}" 
                             IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}">
                    </TextBox>
                </c1:C1InputBase>

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

                <c1:C1InputNumericBox Header="Age" DataBinding="{Binding Age, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}"
                                    IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1:C1InputNumericBox>

                <c1:C1InputNumericBox Header="Weight" DataBinding="{Binding Weight, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}"
                                    IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1:C1InputNumericBox>

                <c1:C1InputComboBox Header="Occupation" DataBinding="{Binding Occupation, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}" ItemsSource="{Binding Source={StaticResource EnumValues}}"
                                    IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1:C1InputComboBox>

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

                <c1:C1InputCheckBox Header="Active" DataBinding="{Binding Active, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}"
                                    IsReadOnly="{Binding IsReadOnly, ElementName=InputPanel}" LabelForeground="{Binding LabelForeground, ElementName=InputPanel}">
                </c1:C1InputCheckBox>
            </StackPanel>
        </DataTemplate>
        <ItemsPanelTemplate x:Key="ItemsPanel">
            <StackPanel Orientation="Vertical" Margin="100" Background="Wheat"/>
        </ItemsPanelTemplate>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel  Orientation="Horizontal" Margin="10" HorizontalAlignment="Right">
            <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>           
        </StackPanel>
        <c1:C1InputPanel x:Name="InputPanel" Grid.Row="1" Header="Employees" ItemsSource="{Binding CustomerCollectionView}"
                         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}"
                         HeaderFontSize="14" 
                         HeaderFontWeight="Bold" 
                         HeaderBackground="White"
                         HeaderForeground="Black"
                         NavigationBackground="White" 
                         ValidationBackground="White" 
                         FooterBorderStyle="{StaticResource FootBorder}">
            <c1:C1InputPanel.HeaderTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="Custom Header Template" Margin="6" Foreground="Black" />
                    </StackPanel>
                </DataTemplate>
            </c1:C1InputPanel.HeaderTemplate>
        </c1:C1InputPanel>
    </Grid>
</UserControl>
