zoukankan      html  css  js  c++  java
  • [wpf] collectionViewsource 排序 和分组

    xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"

    xmlns:swd="clr-namespace:System.Windows.Data;assembly=PresentationFramework"
     

    <CollectionViewSource x:Key="PeopleResource" Source="{Binding People}">

        <CollectionViewSource.SortDescriptions>
            <scm:SortDescription PropertyName="Age" Direction="Ascending"/>
            <scm:SortDescription PropertyName="LastName" Direction="Ascending"/>
        </CollectionViewSource.SortDescriptions>
        <CollectionViewSource.GroupDescriptions>
            <swd:PropertyGroupDescription PropertyName="Gender"/>
        </CollectionViewSource.GroupDescriptions>
    </CollectionViewSource>
     
    <ListBox ItemsSource="{Binding Source={StaticResource PeopleResource}}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Margin="10 0 10 5">
                    <TextBlock Text="{Binding FirstName}"/>
                    <TextBlock FontWeight="Bold" Text="{Binding LastName}"/>
                    <TextBlock Foreground="Blue" Text="{Binding Age}"/>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
        <ListBox.GroupStyle>
            <GroupStyle>
                <GroupStyle.HeaderTemplate>
                    <DataTemplate>
                        <Border BorderBrush="Gray" BorderThickness="0 0 0 4">
                        <TextBlock FontSize="14" FontWeight="Bold"
                                   Foreground="Gray" Text="{Binding Name}"/>
                        </Border>
                    </DataTemplate>
                </GroupStyle.HeaderTemplate>
            </GroupStyle>
        </ListBox.GroupStyle>
    </ListBox>
  • 相关阅读:
    用css3弹性盒子模型实现九宫格布局
    css布局之左中右结构总结
    内联块inline-block的垂直间隙问题
    Jquery选择器 讲解
    U大师装系统
    陈伟:软件趋势——云物移大智
    asp网站发布步骤总结
    MYfirst
    ASP.net 利用From实现上传文件
    【ASP.NET Core CentOS 发布】(四)在CentOS上安装.NET Core运行时、部署到CentOS
  • 原文地址:https://www.cnblogs.com/nocanstillbb/p/11253617.html
Copyright © 2011-2022 走看看