none
WPF ListView中对中文按照拼音排序 RRS feed

  • 问题

  • People people = new People();
    Person person = new Person() { Firstname = "王Michael", Lastname = "Bookatz" };
    people.Add(person);
    person = new Person() { Firstname = "李Chris", Lastname = "Johnson" };
    people.Add(person);
    person = new Person() { Firstname = "张John", Lastname = "Doe" };
    people.Add(person);
    person = new Person() { Firstname = "周Ann", Lastname = "Other" };
    people.Add(person);
    person = new Person() { Firstname = "卫Jack", Lastname = "Smith" };
    people.Add(person);
    person = new Person() { Firstname = "马Charles", Lastname = "Langford" };
    people.Add(person);
    person = new Person() { Firstname = "马zharles", Lastname = "Nangford" };
    people.Add(person);
    person = new Person() { Firstname = "辛aharles", Lastname = "langford" };
    people.Add(person);

    People是一个ObservableCollection,

    listview.ItemsSource = people ;

    点击排序按钮的时候:

    CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(listview.ItemsSource);
    view.SortDescriptions.Clear();
    view.SortDescriptions.Add(new SortDescription("Firstname", ListSortDirection.Ascending));

    我发现排序是按照内码排序的,不是按照拼音排序的,

    请问如何按照拼音排序?

    2014年4月16日 11:57

答案

全部回复