Windows Phone 7按字母顺序跳转列表组

时间:2013-09-14 23:14:30

标签: windows-phone-7 longlistselector jump-list

我有一个跳转列表,按个别条目分组,但我想按字母表分组列表

var ANBA = from accountsTable in dataSource
           orderby accountsTable.Extra
           group accountsTable by accountsTable.Extra.Substring(0, 1) into c
           orderby c.Key
           select new Group<AccountsTable>(c.Key, c);

this.AccountsList2.ItemsSource = ANBA;

此代码列表中包含小写字母&amp;不同组的大写字母

a
    ab
    ac
    ad
A
    Aa
    Ab
    Ac

如何使它成为小写字母&amp;大写字母将在同一组和&amp;单组中的所有其他字符,如所有数字和&amp;字符

a 
    Aa
    ab
    ad
    AGDS
*
    1
    5000
    @@ASD

1 个答案:

答案 0 :(得分:1)

以下是修改查询的方法:

List<Table> Source = new List<Table>();

var ANBA = from accountsTable in Source 
                  orderby table.Extra
                   group table by (( table.Extra[0]>='a' &&table.Extra[0]<='z' )
                      ||( table.Extra[0]>='A' &&table.Extra[0]<='Z' ) ?table.Extra.Substring(0,1).ToUpper()[0]:'*')  into c
                   orderby c.Key
                   select new Group<Table>(c.Key.ToString(), c);

        this.ANListGropus.ItemsSource = ANBA;