c# - 按类别过滤图像,RSS 阅读器

标签 c# windows-phone-7 collections rss merge

我找到了一个很棒的 RSS 阅读器,它只获取图像。
地址:http://www.kunal-chowdhury.com/2011/08/fetching-picasa-images-through-rss-in.html

我无法弄清楚的是如何让该阅读器仅按所需类别过滤和显示提要中的图像。我不打算将该阅读器用于 Picasa。

我使用的 RSS 提要:http://www.zimo.co/feed/


我创建了一个 ObservableCollection

ObservableCollection<FeedItem> categories;

    public ObservableCollection<FeedItem> Categories
    {
        get { return categories; }
        set
        {
            categories = value;
            OnPropertyChanged("Categories");
        }
    }

并更新代码如下

private void Feed(object sender, DownloadStringCompletedEventArgs e)
    {

        try
        {
            if (!e.Cancelled)
            {
                var xmlElement = XElement.Parse(e.Result);
                FeedItems.Clear();
//added code for pulling all categories for every item in the feed
                foreach (var katItem in from value
                                     in xmlElement.Elements("channel").Elements("item").Elements("category")
                                        select value.Value
                                            into xCategory
                                            where xCategory != null
                                            select new FeedItem { Category = xCategory })
                {
                    Categories.Add(katItem);



                }

                    foreach (var feedItem in from value
                                                 in xmlElement.Elements("channel").Elements("item")
                                             select value.Element("enclosure")
                                                 into xEnclosure
                                                 where xEnclosure != null
                                                 select xEnclosure.Attribute("url")
                                                     into xUrl
                                                     where xUrl != null
                                                     select new FeedItem { Link = xUrl.Value }
                                                       )
                    {

                                            FeedItems.Add(feedItem);
                    }

            }


        }
        catch
        { }
    }

这样我就有了一个集合(类别),我从其中获取了提要中每个项目的所有类别。我想知道的事情。是否可以合并这两个集合,然后按所需类别过滤新集合,以便我只得到所需的图像?

最佳答案

您必须自己解析图像。使用 Picasa 提要,您可以获得图像的显式链接,这些图像稍后可以绑定(bind)到 Image 控件。在您的 Feed 中,我看不到明确的图片链接。

关于c# - 按类别过滤图像,RSS 阅读器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10114837/

相关文章:

c# - IEnumerable 在数组和列表上的表现不同

c# - 如何在 WP7 中的枢轴页面上应用加速度计来导航页面?

WPF 将两个集合合并到一个 DataGrid 中

java - 将对象添加到列表中的 Lambda 表达式

c# - 无法在计算机 '.' 上打开 <MyService> 服务

c# - 如何在配置文件中放置一个 Windows 特殊文件夹

windows-phone-7 - 向 Windows Phone 7 模拟器添加更多音乐?

java - 对象列表中元素的相等性检查

c# - 预处理器指令

c# - 缩放 WP7 应用程序