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.