WPF listview sorting

Source: Internet
Author: User

There are many methods on the Internet, but the content is too comprehensive,CodeIt looks complicated. In fact, many of them control the UI.

 

In WPF, the basic principle of listview sorting is very simple.

 

Listviewcontrol. Items. sortdescriptions. Add (New sortdescription ("name", listsortdirection. Descending ));

 

This statement sets the sortdescriptions attribute of the items of listview. This attribute is a set, which is different from the sorting attribute settings of the familiar SQL or dataview, the sortdescriptions sorting attribute is a data set that can contain many sort descriptions and sort by these descriptions.

 

The sorting description is sortdescription. One of the two attributes is property and ction.

 

Property is the name of the specified sorting field, string type

 

Direction specifies the sort order as backward or order, which is of the listsortdirection type)

 

Therefore, the principle of sorting listview is to add the sortdescription object to sortdescriptions of items of listview, and set the sorting field and order in sortdescription.

 

This principle applies to other sorting functions and UI optimization.

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.