我们使用CollectionView实现了对于绑定数据的导航,除导航功能外,还可以通过CollectionView对数据进行类似于DataView的排序、筛选等功能。一、数据的排序:使用第二十四节的数据源,查询所有的产品信息:1:<Windowx:Class=""2:xmlns="http://schemas./winfx/2006/xaml/presentation"3:xmlns:x="http://schemas./winfx/2006/xaml"4:xmlns:lib="clr-namespace:WPF_24_Library;assembly=WPF_24_Library"5:Title="CollectionViewSortData"Height="300"Width="500">6:<>7:<ObjectDataProviderx:Key="myDataSource"8:ObjectType="{x:Typelib:DataControl}"9:MethodName="GetAllProductInfo"/>10:</>11:<GridMargin="5">12:<>13:<RowDefinition/>14:<RowDefinitionHeight="50"/>15:</>16:<="0"17:DataContext="{StaticResourcemyDataSource}"18:ItemsSource="{Binding}">19:<>20:<DataTemplate>21:<WrapPanel>22:<TextBlockText="{BindingPath=ProductID}"Width="50"/>23:<TextBlockText="{BindingPath=ProductName}"Width="300"/>24:<TextBlockText="{BindingPath=UnitPrice}"Width="50"/>25:</WrapPanel>26:</DataTemplate>27:</>28:</ListBox>29:<="1"VerticalAlignment="Center"HorizontalAlignment="Center">30:<TextBlockText="第一排序:"VerticalAlignment="Center"/>31:<ComboBoxSelectedIndex="0"Width="80"x:Name="cmbColumnA">32:<>33:<ComboBoxItemTag="ProductID">产品编号</ComboBoxItem>34:<ComboBoxItemTag="ProductName">产品名称</ComboBoxItem>35:<ComboBoxItemTag="UnitPrice">产品单价</Comb
WPF第十章排序筛选 来自淘豆网www.taodocs.com转载请标明出处.