FormItem

Kino.Toolkit.Wpf使用_用户信息

<UserControl x:Class="仓库进销存.Views.ProductStore"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:kino="https://github.com/DinoChan/Kino.Toolkit.Wpf"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800" Background="White" >
    <UserControl.Resources>
        <DataTemplate x:Key="TopHeaderTemplate">
            <TextBlock Text="{Binding}"
                       VerticalAlignment="Top"
                       HorizontalAlignment="Right"
                       Margin="0,1,0,0" />
        </DataTemplate>
    </UserControl.Resources>

    <StackPanel>
        <StackPanel Width="500" 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>
        </StackPanel>

    </StackPanel>
</UserControl>
NomalForm

Kino.Toolkit.Wpf使用_i++_02

<kino:Form Width="500"
               HorizontalAlignment="Left"
               Header="NormalForm">
    <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:FormSeparator />

    <kino:FormTitle Content="家庭信息"
                        Description="填写家庭信息可以让我们给您提供更好的服务。" />

    <TextBox kino:Form.Label="父"
             kino:Form.Description="可以不填" />
    <TextBox kino:Form.Label="母"
             kino:Form.Description="可以不填" />
    <TextBox kino:Form.Label="伴侣"
             kino:Form.Description="可以没有"
             kino:Form.IsRequired="True" />
    <StackPanel kino:Form.Label="性别"
                Orientation="Horizontal">
        <RadioButton Content="男"
                     GroupName="Sex" />
        <RadioButton Content="女"
                     GroupName="Sex"
                     Margin="8,0,0,0" />
    </StackPanel>
    <TextBox AcceptsReturn="True"
             kino:Form.Label="备注"
             kino:Form.LabelTemplate="{StaticResource TopHeaderTemplate}"
             VerticalScrollBarVisibility="Auto"
             Height="100" />
    <kino:Form.FunctionBar>
        <kino:FormFunctionBar>
            <kino:ExtendedButton Content="OK"
                             Click="OnOK"
                             IsDefault="True" />
            <kino:ExtendedButton Content="Cancel"
                             IsCancel="True"
                             Click="OnCancel" />

        </kino:FormFunctionBar>
    </kino:Form.FunctionBar>
</kino:Form>

显示隐藏Form

Kino.Toolkit.Wpf使用_i++_03

<kino:Form Width="500"
               HorizontalAlignment="Left">
    <CheckBox kino:Form.Label="显示额外信息"
              x:Name="ExtraInformationCheckBox" />
    <Grid kino:Form.IsItemItsOwnContainer="True"
          Visibility="{Binding IsChecked,ElementName=ExtraInformationCheckBox,Converter={StaticResource BooleanToVisibilityConverter}}">
        <kino:Form Grid.IsSharedSizeScope="False"
                       Padding="0">
            <ComboBox kino:Form.Label="国家" />
            <TextBox kino:Form.Label="父"
                     kino:Form.Description="可以不填" />
            <TextBox kino:Form.Label="母"
                     kino:Form.Description="可以不填" />
        </kino:Form>
    </Grid>
    <TextBox kino:Form.Label="地址"
             Visibility="{Binding IsChecked,ElementName=ExtraInformationCheckBox,Converter={StaticResource BooleanToVisibilityConverter}}"/>
</kino:Form>

使用Expander分组

Kino.Toolkit.Wpf使用_i++_04

<kino:Form Width="500"
               HorizontalAlignment="Left">
    <Expander kino:Form.IsItemItsOwnContainer="True"
              Header="用户信息"
              IsExpanded="True">
        <kino:Form Grid.IsSharedSizeScope="False"
                       Padding="0">
            <TextBox kino:Form.Label="用户名"
                     kino:Form.IsRequired="True"
                     Text="{Binding Name,Mode=TwoWay}" />
            <PasswordBox kino:Form.Label="密码"
                         kino:Form.IsRequired="True" />
        </kino:Form>
    </Expander>
    <Expander kino:Form.IsItemItsOwnContainer="True"
              Header="其它信息"
              IsExpanded="True">
        <kino:Form Grid.IsSharedSizeScope="False"
                       Padding="0">
            <ComboBox kino:Form.Label="国家" />
            <TextBox kino:Form.Label="父"
                     kino:Form.Description="可以不填" />
            <TextBox kino:Form.Label="母"
                     kino:Form.Description="可以不填" />
        </kino:Form>
    </Expander>
</kino:Form>

ItemsPanelTemplate

Kino.Toolkit.Wpf使用_i++_05

<kino:Form Width="500"
               HorizontalAlignment="Left">
    <kino:Form.Resources>
        <Style TargetType="kino:FormItem"
               x:Key="FromItemStyle"
               BasedOn="{StaticResource ControlPanelFromItemStyle}">
            <Setter Property="Margin"
                    Value="8" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="kino:FormItem">
                        <StackPanel x:Name="Root">
                            <ContentPresenter Content="{TemplateBinding Label}"
                                              ContentTemplate="{TemplateBinding LabelTemplate}" />
                            <ContentPresenter Margin="{TemplateBinding Padding}"
                                              x:Name="ContentPresenter"
                                              Height="50" />
                            <ContentPresenter Visibility="{Binding Description,RelativeSource={RelativeSource Mode=TemplatedParent},Converter={StaticResource NullToValueConverter},ConverterParameter=Collapsed,FallbackValue=Visible}"
                                              Margin="0,2,0,0"
                                              Content="{TemplateBinding Description}"
                                              TextBlock.Foreground="{Binding Source={x:Static SystemColors.GrayTextBrush}}" />
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <ItemsPanelTemplate x:Key="ItemsPanelTemplate">
            <UniformGrid Rows="1" />
        </ItemsPanelTemplate>
    </kino:Form.Resources>
    <Expander kino:Form.IsItemItsOwnContainer="True"
              Header="用户信息"
              IsExpanded="True">
        <kino:Form Grid.IsSharedSizeScope="False"
                       Padding="0"
                       ItemContainerStyle="{StaticResource FromItemStyle}"
                       ItemsPanel="{StaticResource ItemsPanelTemplate}">
            <TextBox kino:Form.Label="用户名" />
            <TextBox kino:Form.Label="级别" />
            <TextBox kino:Form.Label="备注" />

        </kino:Form>
    </Expander>
    <Expander kino:Form.IsItemItsOwnContainer="True"
              Header="其它信息"
              IsExpanded="True">
        <kino:Form Grid.IsSharedSizeScope="False"
                       Padding="0"
                       ItemContainerStyle="{StaticResource FromItemStyle}"
                       ItemsPanel="{StaticResource ItemsPanelTemplate}">
            <TextBox kino:Form.Label="学校" />
            <TextBox kino:Form.Label="职业" />
            <TextBox kino:Form.Label="证书" />
        </kino:Form>
    </Expander>
    <Expander kino:Form.IsItemItsOwnContainer="True"
              Header="住址信息"
              IsExpanded="True">
        <kino:Form Grid.IsSharedSizeScope="False"
                       Padding="0"
                       ItemContainerStyle="{StaticResource FromItemStyle}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                    </Grid>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <TextBox kino:Form.Label="邮编" />
            <kino:FormItem Label="住址"
                               Grid.Column="1"
                               Grid.ColumnSpan="2">
                <TextBox />
            </kino:FormItem>
        </kino:Form>
    </Expander>
</kino:Form>

DataGrid

存在两种模式
Kino.Toolkit.Wpf使用_microsoft_06

<TextBlock Text="Selection Mode"
           Margin="8,8,8,0" />
<ComboBox Width="300"
          HorizontalAlignment="Left"
          Margin="8"
          x:Name="SelectionComboBox" />
<kino:ExtendedDataGrid ItemsSource="{Binding}" 
               AutoGenerateColumns="False"
               SelectionMode="{Binding ElementName=SelectionComboBox,Path=SelectedItem}"
               IsReadOnly="True">
    <DataGrid.Columns>
        <DataGridTextColumn Header="Name"
                        Binding="{Binding Name}"
                        Width="200" />
    </DataGrid.Columns>
</kino:ExtendedDataGrid>

var list = new List<TestModel>();
for (int i = 0; i < 10; i++)
{
    list.Add(new TestModel { Name = "this is " + i });
}
DataContext = list;
DataPager分页

Kino.Toolkit.Wpf使用_xml_07

<extend:ColorToSolidColorBrushConverter x:Key="ColorToSolidBrushConverter" />
<Style TargetType="kino:DataPager">
    <Setter Property="NumericButtonCount"
            Value="{Binding Value, ElementName=NumericButtonCount}" />
    <Setter Property="AutoEllipsis"
            Value="{Binding IsChecked, ElementName=AutoEllipsis}" />
    <Setter Property="IsTotalItemCountFixed"
            Value="{Binding IsChecked, ElementName=TotalItemCountFixed}" />
    <Setter Property="Source"
            Value="{Binding}" />
    <Setter Property="HorizontalAlignment"
            Value="Left" />
    <Setter Property="Foreground"
            Value="{Binding SelectedColor,ElementName=ColorPicker,Converter={StaticResource ColorToSolidBrushConverter}}" />
</Style>


<kino:Form>
    <kino:DataPager DisplayMode="FirstLastNumeric"
                        kino:Form.Label="FirstLastNumeric" />
    <kino:DataPager DisplayMode="FirstLastPreviousNext"
                        kino:Form.Label="FirstLastPreviousNext" />
    <kino:DataPager DisplayMode="FirstLastPreviousNextNumeric"
                        kino:Form.Label="FirstLastPreviousNextNumeric" />
    <kino:DataPager DisplayMode="Numeric"
                        kino:Form.Label="Numeric" />
    <kino:DataPager DisplayMode="PreviousNext"
                        kino:Form.Label="PreviousNext" />
    <kino:DataPager DisplayMode="PreviousNextNumeric"
                        kino:Form.Label="PreviousNextNumeric" />
</kino:Form>
<StackPanel Grid.Column="1">
    <ListBox ItemsSource="{Binding}"
             DisplayMemberPath="Name"
             Margin="4"
             Height="120" />
    <DataGrid Height="120"
              AutoGenerateColumns="False"
              IsReadOnly="True"
              ItemsSource="{Binding}"
              Margin="4">
        <DataGrid.Columns>
            <DataGridTextColumn Header="Name"
                                Binding="{Binding Name}"
                                Width="300"
                                SortMemberPath="Name" />
        </DataGrid.Columns>
    </DataGrid>
</StackPanel>


<kino:Form ItemContainerStyle="{StaticResource ControlPanelFromItemStyle}"
               HorizontalAlignment="Left">
    <CheckBox x:Name="AutoEllipsis"
              kino:Form.Label="AutoEllipsis" />
    <CheckBox x:Name="TotalItemCountFixed"
              kino:Form.Label="IsTotalItemCountFixed"
              IsChecked="True" />
    <extend:IntegerUpDown x:Name="NumericButtonCount"
                          kino:Form.Label="NumericButtonCount"
                          Value="5"
                          Minimum="0"
                          Maximum="20" />
    <extend:IntegerUpDown Value="{Binding PageSize, Mode=TwoWay}"
                          kino:Form.Label="PageSize"
                          Minimum="1" />
    <extend:ColorPicker SelectedColor="Black"
                        kino:Form.Label="Foreground"
                        x:Name="ColorPicker" />
</kino:Form>

var list = new List<TestModel>();
for (int i = 0; i < 99; i++)
{
    list.Add(new TestModel { Name = "this is " + i });
}
var pagedCollectionView = new PagedCollectionView(list);
pagedCollectionView.PageSize = 10;
DataContext = pagedCollectionView;