我有ItemsControl
ScrollViewer
它显示新馈送。 Answer为什么我不使用ListBox
。我显示40-50个新闻,然后,我按下按钮,更新新闻源集合,然后 - 将其放入ItemsControl
。但我有OutOfMemoryException
,我可以理解为什么。我用来获取更多新闻源的方法与第一次加载数据的方法相同,所以我认为问题不在其中。但这是代码
void c_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
XDocument xml = XDocument.Load(e.Result);
App.WriteToIsoStorage(xml.ToString(), "items.xml");
App.New_From = (string)xml.Element("response").Element("new_from").Value;
var inf = from c in xml.Descendants("item")
select c;
foreach (var item in inf)
{
if ((string)item.Element("type").Value != "friend" && item.Element("type").Value != "photo_tag" && (string)item.Element("type").Value != "photo" && item.Element("type").Value != "wall_photo")
{
New new1 = new New();
GetIds(item, new1, out new1);
GetIcons(item, new1, out new1);
if (item.Element("attachment") != null)
{
var vd = from c in item.Descendants("attachment")
select c;
foreach (var content in vd)
{
if (content.Element("audio") != null) GetAudios(content, new1.audioAttachments, out new1.audioAttachments);
if (content.Element("photo") != null && (string)item.Element("type").Value != "photo" && item.Element("type").Value != "wall_photo") GetPhotos(content, new1.photoAttachments, out new1.photoAttachments);
if (content.Element("video") != null) GetVideos(content, new1.videoAttachments, out new1.videoAttachments);
if (content.Element("link") != null) GetUrls(content, new1, out new1);
}
}
if (item.Element("type").Value != "photo" && item.Element("type").Value != "wall_photo" && item.Element("type").Value != "photo_tag")
NewsList.Add(new1);
this.ItemsControl.Items.Add(new1);
new1 = null;
}
IEnumerable<XElement> profiles = from c in xml.Descendants("user") //
select c;
IEnumerable<XElement> groups = from c in xml.Descendants("group") //
select c;
GetNames(profiles, groups);
}
}
这里的VS显示