text: ﻿<local:SamplePage x:Class="Kino.Toolkit.Wpf.Samples.FormItemSample"
                    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"
                    mc:Ignorable="d"
                    xmlns:local="clr-namespace:Kino.Toolkit.Wpf.Samples"
                    xmlns:kino="clr-namespace:Kino.Toolkit.Wpf;assembly=Kino.Toolkit.Wpf"
                    Header="Form"
                    Link="https://github.com/DinoChan/Kino.Toolkit.Wpf/tree/master/Kino.Toolkit.Wpf/Kino.Toolkit.Wpf/Form"
                    d:DesignHeight="6950"
                    d:DesignWidth="800"
                    BorderBrush="Black">
      <local:SamplePage.DataContext>
          <local:FormTestModel Name="Username" />
      </local:SamplePage.DataContext>
      <local:SamplePage.Resources>
          <DataTemplate x:Key="TopHeaderTemplate">
              <TextBlock Text="{Binding}"
                         VerticalAlignment="Top"
                         HorizontalAlignment="Right"
                         Margin="0,1,0,0" />
          </DataTemplate>
          <kino:EmptyObjectToVisibilityConverter x:Key="EmptyObjectToVisibilityConverter" />
          <kino:BoolToObjectConverter x:Key="BoolToObjectConverter" />
          <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
  
  
          <Style TargetType="kino:FormItem"
                 x:Key="FormItemStyle">
              <Setter Property="Padding"
                      Value="11,0,3,0" />
              <Setter Property="Template">
                  <Setter.Value>
                      <ControlTemplate TargetType="kino:FormItem">
                          <Grid x:Name="Root"
                                Height="25">
                              <Grid.ColumnDefinitions>
                                  <ColumnDefinition Width="Auto"
                                                    SharedSizeGroup="Header"
                                                    MinWidth="100" />
                                  <ColumnDefinition />
                              </Grid.ColumnDefinitions>
                              <ContentPresenter Content="{TemplateBinding Label}"
                                                VerticalAlignment="Center"
                                                HorizontalAlignment="Right"
                                                TextBlock.Foreground="#FF777777" />
                              <ContentPresenter Grid.Column="1"
                                                Width="300"
                                                Margin="{TemplateBinding Padding}"
                                                x:Name="ContentPresenter"
                                                VerticalAlignment="Center" />
                          </Grid>
                      </ControlTemplate>
                  </Setter.Value>
              </Setter>
          </Style>
  
          <Style TargetType="kino:FormItem"
                 x:Key="EditableFormItemStyle">
              <Setter Property="Template">
                  <Setter.Value>
                      <ControlTemplate TargetType="kino:FormItem">
                          <Grid x:Name="Root">
                              <Grid.ColumnDefinitions>
                                  <ColumnDefinition Width="Auto"
                                                    SharedSizeGroup="Header"
                                                    MinWidth="100" />
                                  <ColumnDefinition />
                              </Grid.ColumnDefinitions>
                              <ContentPresenter Content="{TemplateBinding Label}"
                                                VerticalAlignment="Center"
                                                HorizontalAlignment="Right"
                                                TextBlock.Foreground="#FF777777" />
                              <TextBox Grid.Column="1"
                                       Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=Content.Text}"
                                       Margin="{TemplateBinding Padding}"
                                       Width="300"
                                       x:Name="ContentPresenter"
                                       VerticalContentAlignment="Center"
                                       Height="25" />
                          </Grid>
                      </ControlTemplate>
                  </Setter.Value>
              </Setter>
          </Style>
  
          <Style TargetType="kino:Form">
              <Setter Property="ScrollViewer.VerticalScrollBarVisibility"
                      Value="Disabled" />
          </Style>
      </local:SamplePage.Resources>
      <StackPanel Background="White">
          <local:SampleSection Header="FormItem">
              <kino:ExtendedStackPanel Width="500"
                                       Spacing="12"
                                       HorizontalAlignment="Left"
                                       Grid.IsSharedSizeScope="True">
                  <kino:FormTitle Content="用户信息" />
                  <kino:FormItem Label="用户名"
                                 IsRequired="True">
                      <TextBox Text="{Binding Name,Mode=TwoWay}" />
                  </kino:FormItem>
                  <kino:FormItem Label="密码"
                                 IsRequired="True">
                      <PasswordBox />
                  </kino:FormItem>
                  <kino:FormItem Label="国家与地区(请选择居住地)">
                      <ComboBox />
                  </kino:FormItem>
                  <kino:FormSeparator />
  
                  <kino:FormTitle Content="家庭信息"
                                  Description="填写家庭信息可以让我们给您提供更好的服务。" />
                  <kino:FormItem Label="父"
                                 Description="可以不填">
                      <TextBox />
                  </kino:FormItem>
                  <kino:FormItem Label="母"
                                 Description="可以不填">
                      <TextBox />
                  </kino:FormItem>
                  <kino:FormItem Label="伴侣"
                                 Description="可以没有"
                                 IsRequired="True">
                      <TextBox />
                  </kino:FormItem>
                  <kino:FormItem Label="性别">
                      <StackPanel Orientation="Horizontal">
                          <RadioButton Content="男"
                                       GroupName="Sex" />
                          <RadioButton Content="女"
                                       GroupName="Sex"
                                       Margin="8,0,0,0" />
                      </StackPanel>
                  </kino:FormItem>
                  <kino:FormItem Label="备注"
                                 LabelTemplate="{StaticResource TopHeaderTemplate}">
                      <TextBox AcceptsReturn="True"
                               VerticalScrollBarVisibility="Auto"
                               Height="100" />
                  </kino:FormItem>
              </kino:ExtendedStackPanel>
              <local:SampleSection.SourceCodes>
                  <local:SourceCodeModel SourceCodeType="Xaml"
                                         Haader="FormItemSample.xaml"
                                         CodeSource="/Kino.Toolkit.Wpf.Samples;component/SourceFiles/FormItemSample.Section1.txt" />
              </local:SampleSection.SourceCodes>
          </local:SampleSection>
  
          <local:SampleSection Header="使用样式">
              <local:SampleSection.Resources>
                  <Style TargetType="kino:FormItem">
                      <Setter Property="Padding"
                              Value="0,4,0,0" />
                      <Setter Property="Template">
                          <Setter.Value>
                              <ControlTemplate TargetType="kino:FormItem">
                                  <StackPanel x:Name="Root">
                                      <StackPanel Orientation="Horizontal">
                                          <ContentPresenter Content="{TemplateBinding Label}"
                                                            ContentTemplate="{TemplateBinding LabelTemplate}" />
                                          <TextBlock x:Name="IsRequiredMark"
                                                     Margin="2,0,0,0"
                                                     VerticalAlignment="Center"
                                                     Grid.Column="2"
                                                     Visibility="{Binding IsRequired,RelativeSource={RelativeSource Mode=TemplatedParent},Converter={StaticResource BooleanToVisibilityConverter}}"
                                                     Text="*"
                                                     Foreground="Red" />
                                          <Grid ToolTip="{TemplateBinding Description}"
                                                Visibility="{Binding Description,RelativeSource={RelativeSource Mode=TemplatedParent},Converter={StaticResource EmptyObjectToVisibilityConverter}}"
                                                Margin="4,0,0,0"
                                                Background="Transparent">
                                              <TextBlock Style="{StaticResource FontAwesome}"
                                                         Text="&#xf059;"
                                                         VerticalAlignment="Center"
                                                         Foreground="LightSeaGreen"
                                                         FontSize="12" />
                                          </Grid>
                                      </StackPanel>
                                      <ContentPresenter Margin="{TemplateBinding Padding}"
                                                        x:Name="ContentPresenter" />
                                  </StackPanel>
                              </ControlTemplate>
                          </Setter.Value>
                      </Setter>
                  </Style>
              </local:SampleSection.Resources>
              <kino:Form Width="400"
                         kino:FocusService.IsAutoFocus="False"
                         HorizontalAlignment="Left"
                         Header="登录">
                  <kino:FormTitle Content="用户信息" />
  
                  <TextBox kino:Form.Label="用户名"
                           kino:Form.IsRequired="True"
                           Text="{Binding Name,Mode=TwoWay}" />
  
                  <PasswordBox kino:Form.Label="密码"
                               kino:Form.IsRequired="True" />
                  <ComboBox kino:Form.Label="国家"
                            kino:Form.Description="请选择先居住地" />
  
                  <kino:Form.FunctionBar>
                      <kino:FormFunctionBar>
                          <kino:ExtendedButton Content="OK"
                                               Click="OnOK"
                                               IsDefault="True" />
                          <kino:ExtendedButton Content="Cancel"
                                               IsCancel="True" />
  
                      </kino:FormFunctionBar>
                  </kino:Form.FunctionBar>
              </kino:Form>
              <local:SampleSection.SourceCodes>
                  <local:SourceCodeModel SourceCodeType="Xaml"
                                         Haader="FormItemSample.xaml"
                                         CodeSource="/Kino.Toolkit.Wpf.Samples;component/SourceFiles/FormItemSample.Section2.txt" />
              </local:SampleSection.SourceCodes>
          </local:SampleSection>
          <local:SampleSection Header="可编辑">
              <StackPanel HorizontalAlignment="Left">
                  <StackPanel.Resources>
                      <Style TargetType="kino:Form"
                             BasedOn="{StaticResource {x:Type kino:Form}}">
                          <Setter Property="Grid.IsSharedSizeScope"
                                  Value="False" />
                      </Style>
                  </StackPanel.Resources>
                  <kino:PageTitle>
                      <Grid>
                          <TextBlock Text="Responsive" />
                          <CheckBox HorizontalAlignment="Right"
                                    Content="Can Edit"
                                    FontSize="12"
                                    VerticalAlignment="Center"
                                    Checked="OnCanEditChecked"
                                    Unchecked="OnCanEditUnchecked" />
                      </Grid>
                  </kino:PageTitle>
                  <WrapPanel x:Name="Root"
                             Grid.IsSharedSizeScope="True">
                      <kino:Form>
                          <kino:FormTitle Content="Product" />
                          <TextBlock Text="1234999"
                                     kino:Form.Label="Product ID" />
                          <TextBlock Text="Power Projector 4713"
                                     kino:Form.Label="IGNORE" />
                          <TextBlock Text="Projector (PR)"
                                     kino:Form.Label="Category" />
                          <TextBlock Text="A very powerful projector"
                                     kino:Form.Label="Description" />
                          <TextBlock Text="856.49 EUR"
                                     kino:Form.Label="Price" />
                      </kino:Form>
  
                      <kino:Form>
                          <kino:FormTitle Content="Specification" />
                          <TextBlock Text="51 cm"
                                     kino:Form.Label="Width" />
                          <TextBlock Text="42 cm"
                                     kino:Form.Label="Depth" />
                          <TextBlock Text="18 cm"
                                     kino:Form.Label="Height" />
                          <TextBlock Text="1,467 g"
                                     kino:Form.Label="Weight" />
                      </kino:Form>
  
                  </WrapPanel>
              </StackPanel>
              <local:SampleSection.SourceCodes>
                  <local:SourceCodeModel SourceCodeType="Xaml"
                                         Haader="FormItemSample.xaml"
                                         CodeSource="/Kino.Toolkit.Wpf.Samples;component/SourceFiles/FormItemSample.Section3.txt" />
                  <local:SourceCodeModel SourceCodeType="CSharp"
                                         Haader="FormItemSample.xaml.cs"
                                         CodeSource="/Kino.Toolkit.Wpf.Samples;component/SourceFiles/FormItemSample.Section4.txt" />
              </local:SampleSection.SourceCodes>
          </local:SampleSection>
          <local:SampleSection Header="Responsive Form">
              <Button Content="Show Responsive Form Dialog"
                      Click="OnShowResponsiveDialog"
                      HorizontalAlignment="Left" />
          </local:SampleSection>
  
          <!--<Button Content="OK"
                  VerticalAlignment="Center" Margin="5"
                           IsDefault="True" />
          <Button Content="Cancel"
                  VerticalAlignment="Center"
                  Margin="5"
                  IsCancel="True" />-->
      </StackPanel>
  </local:SamplePage>
  