【问题标题】:Windows Phone 7 Jump List Groups By Alphabetical OrderWindows Phone 7 按字母顺序跳转列表组
【发布时间】:2013-09-14 23:14:30
【问题描述】:

我有一个按单个条目分组的跳转列表,但我想按字母对列表进行分组

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;

此代码使用不同组的小写字母和大写字母列表

a
    ab
    ac
    ad
A
    Aa
    Ab
    Ac

如何使小写字母和大写字母在同一组中以及单个组中的所有其他字符(如所有数字和字符)中

a 
    Aa
    ab
    ad
    AGDS
*
    1
    5000
    @@ASD

【问题讨论】:

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


    【解决方案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;
    

    【讨论】:

    • 我还刚刚在 extra 上添加了“排序依据”,以便子项目也按字母顺序排序
    • 嗨,您更新的代码在此工作之前给了我错误代码
    • 'App.Accounts.Group.Group(string, System.Collections.Generic.IEnumerable)' 的最佳重载方法匹配有一些无效参数跨度>
    • 参数 1:无法从 'char' 转换为 'string'
    • 更新为在新组中添加 ToString(c.Key.ToString(), c);
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-19
    • 2018-09-15
    • 1970-01-01
    • 2021-06-25
    相关资源
    最近更新 更多