我有一个 Silverlight 2.0 列表框,它从 @SharePoint 2007 的自定义列表中读取数据。我如何限制在加载 Page.xaml 时显示的项目数?
我这里有@Page.xaml.cs:
private void ProcessResponse()
{
XDocument results = XDocument.Parse(_responseString);
_StaffNews = (from item in results.Descendants(XName.Get("row", "#RowsetSchema"))
//where !item.Element("NewsThumbnail").Attribute("src").Value.EndsWith(".gif")
select new StaffNews()
{
Title = item.Attribute("ows_Title").Value,
NewsBody = item.Attribute("ows_NewsBody").Value,
NewsThumbnail = FormatImageUrl(item.Attribute("ows_NewsThumbnail").Value),
DatePublished = item.Attribute("ows_Date_Published").Value,
PublishedBy = item.Attribute("ows_PublishedBy").Value,
}).ToList();
this.DataContext = _StaffNews;
//NewsList.SelectedIndex = -1;
}
请您参考如下方法:
您可以将 .Take(20) 放在 ToList() 后面,以便仅从列表中取出 20 项。
