WPF and Silverlight Learning notes (25)

Source: Internet
Author: User

WPF and Silverlight Learning notes (25): Using CollectionView to implement sorting, filtering, grouping of bound data

In the 23rd section, we use CollectionView to implement the navigation of bound data, in addition to navigation function, but also through CollectionView to the data similar to DataView sorting, filtering and other functions.

One, the data sorting:

Use the data source in section 24th to query all product information:

1: <window x:class= "Wpf_24.collectionviewsortdata"
2:xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation& quot;
3:xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"
4:xmlns:lib= "Clr-namespace:wpf_24_library;assembly=wpf_24_library"
5:title= "Collectionviewsortdata" height= "width=" >
6: <Window.Resources>
7: <objectdataprovider x:key= "myDataSource"
8:objecttype= "{x:type Lib:datacontrol}"
9:methodname= "Getallproductinfo"/>
: </Window.Resources>
One: <grid margin= "5" >
<Grid.RowDefinitions>
<rowdefinition/>
<rowdefinition height= "/>"
: </Grid.RowDefinitions>
: <listbox grid.row= "0"
17:datacontext= "{StaticResource myDataSource}"
18:itemssource= "{Binding}" >
: <ListBox.ItemTemplate>
<DataTemplate>
<WrapPanel>
<textblock text= "{Binding Path=productid}" width= "-"/>
<textblock text= "{Binding path=productname}" width= "-"/>
<textblock text= "{Binding path=unitprice}" "Width="/>
: </WrapPanel>
: </DataTemplate>
: </ListBox.ItemTemplate>
: </ListBox>
: <wrappanel grid.row= "1" verticalalignment= "center" horizontalalignment= "Center" >
<textblock text= "First sort:" verticalalignment= "Center"/>
: <combobox selectedindex= "0" width= "x:name=" Cmbcolumna ">
<ComboBox.Items>
: <comboboxitem tag= "ProductID" > Product No. </ComboBoxItem>
: <comboboxitem tag= "ProductName" > Product name </ComboBoxItem>
£ <comboboxitem tag= "UnitPrice" > Product price </ComboBoxItem>
-</ComboBox.Items>
Panax Notoginseng: </ComboBox>
<textblock text= "Second order:" verticalalignment= "Center"/>
: <combobox selectedindex= "0" width= "x:name=" CMBCOLUMNB ">
<ComboBox.Items>
: <comboboxitem tag= "ProductID" > Product No. </ComboBoxItem>
: <comboboxitem tag= "ProductName" > Product name </ComboBoxItem>
<comboboxitem tag= "UnitPrice" > Product price </ComboBoxItem>
: </ComboBox.Items>
: </ComboBox>
<button content= "Sort" margin= "10,0,0,0" click= "Button_Click"/>
: </WrapPanel>
</Grid>
: </Window>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.