由于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

 

 截图如下:

对Scott Gu的Silverlight Sample--DiggSample的修改

 

 [代码] 代码下载

相关文章:

  • 2022-12-23
  • 2021-07-05
  • 2021-12-16
  • 2021-11-23
  • 2021-05-19
  • 2021-07-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-29
  • 2021-04-11
  • 2021-12-15
  • 2022-12-23
  • 2022-02-23
  • 2022-12-23
相关资源
相似解决方案