zoukankan      html  css  js  c++  java
  • ListBox item Sort

    将Rss内容读取到Listbox control中, 然后实现按照标题或发布日期进行排序。

            private void ListItemSort(string type)
            {
                if (type == "title")
                {
                    var list = ItemBox.Items.Cast<SyndicationItem>().OrderBy(item => item.Title.Text).ToList();
                    if (ItemBox.ItemsSource != null)
                        ItemBox.ItemsSource = null;
                    ItemBox.Items.Clear();
                    foreach (SyndicationItem item in list)
                    {
                        ItemBox.Items.Add(item);
                    }
                }
                else if (type == "date")
                {
                    var list = ItemBox.Items.Cast<SyndicationItem>().OrderBy(item => item.PublishDate.LocalDateTime).ToList();
                    if (ItemBox.ItemsSource != null)
                        ItemBox.ItemsSource = null;
                    ItemBox.Items.Clear();
                    foreach (SyndicationItem item in list)
                    {
                        ItemBox.Items.Add(item);
                    }
                }
            }


    需要这两个类库:

    using System.ServiceModel.Syndication;
    using System.Collections;
  • 相关阅读:
    shell的正则表达式
    shell语法
    shell通配符
    shell小命令
    DNS
    CCNA参考链接
    Network problem solving flow chart
    我是一个路由器
    我是一个网卡
    Chrome
  • 原文地址:https://www.cnblogs.com/qixue/p/3196277.html
Copyright © 2011-2022 走看看