C# 按类别筛选图像,RSS阅读器
我发现了一个很棒的RSS阅读器,它只获取图像。C# 按类别筛选图像,RSS阅读器,c#,windows-phone-7,collections,rss,merge,C#,Windows Phone 7,Collections,Rss,Merge,我发现了一个很棒的RSS阅读器,它只获取图像。 地点: 我搞不懂的是如何让阅读器过滤并只按所需类别显示提要中的图像。我不打算把那个阅读器用在Picasa上 我使用的RSS源: 我创建了一个可观察的集合 ObservableCollection<FeedItem> categories; public ObservableCollection<FeedItem> Categories { get { return categories;
地点: 我搞不懂的是如何让阅读器过滤并只按所需类别显示提要中的图像。我不打算把那个阅读器用在Picasa上 我使用的RSS源:
我创建了一个可观察的集合
ObservableCollection<FeedItem> categories;
public ObservableCollection<FeedItem> Categories
{
get { return categories; }
set
{
categories = value;
OnPropertyChanged("Categories");
}
}
这样我就有了一个集合(类别),在其中我从提要中的每个项目中获取所有类别。我想知道的事情。是否可以合并这两个集合,然后按所需类别筛选新集合,以便只获取所需图像?您必须自己解析图像。使用Picasa提要,您可以获得指向图像的显式链接,这些链接稍后可以绑定到
图像
控件。对于您的订阅源,我看不到明确的图像链接。但此阅读器按原样处理我的订阅源。你是说它不能适应过滤吗?它可以,只要你想办法从提要内部获取图像链接。读者阅读整个提要,只从其中获取图像。现在我需要一个过滤环。纠正我,如果我认为RSS阅读器的代码错了,我不是很有经验的程序员。
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
{ }
}