




















由于Scott Gu的Sample中的数据已经不能获取,于是花了点时间把数据获取重写了下
仍然是Linq to XML,具体代码如下
XDocument xmlStories = XDocument.Parse(xmlContent);
XNamespace digg = "http://digg.com/docs/diggrss/";
XNamespace media = "http://search.yahoo.com/mrss/";
var stories = from story in xmlStories.Descendants("item")
where story.Element(media + "thumbnail") != null &&
story.Element(media + "thumbnail").Attribute("url") != null &&
story.Element(media + "thumbnail").Attribute("url").Value.EndsWith(".jpg")
select new DiggStory
{
//Id = (int)story.Attribute("id"),
Title = ((string)story.Element("title")).Trim(),
Description = Regex.Replace(((string)story.Element("description")).Trim(), @"<(.[^>]*)>", "", RegexOptions.IgnoreCase),
ThumbNail = (string)story.Element(media + "thumbnail").Attribute("url"),
HrefLink = new Uri((string)story.Element("link")),
NumDiggs = (int)story.Element(digg + "diggCount"),
UserName = (string)story.Element(digg + "submitter").Element(digg + "username"),
};
还有一个地方,大家在做这个Demo的时候,注意在SL3中已经没有WateredTextBox,新的控件为DataPickerTextBox
截图如下:

[代码] 代码下载
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。