2010-11-03 101 views
0

在透视中,我加载图像,每个图像都动态地创建为透视项目,其源代码是URL。它适用于10张图像,但如果有更多图像会崩溃。windows phone 7:从URL加载图像导致应用程序崩溃

问题是在调试中也没有显示错误。 这是我使用添加图片作为支点项目

foreach (Photo photo in Albumcollection) 
      { 
       PivotItem pivotItem = new PivotItem(); 

       Image image = new Image(); 
       image.Height = 450; 
       image.Width = 450; 
       BitmapImage bitmapImage = new BitmapImage(); 
       bitmapImage.UriSource = new Uri(photo.URL, UriKind.Absolute); 
       image.CacheMode = new BitmapCache(); 
       image.Source = bitmapImage; 
       image.Stretch = Stretch.Uniform; 

       image.Margin = new Thickness(0); 

       StackPanel stackPanel = new StackPanel(); 
       stackPanel.Children.Add(image); 

       pivotItem.Content = stackPanel; 
       pivotItem.Header = photo.Name; 

       PvtPhotos.Items.Add(pivotItem); 

      } 

什么是崩溃的原因以及如何解决的代码?

+0

内存消耗这岂不是抛出一个异常,当它崩溃,这将触发中断到调试? – 2010-11-03 09:21:07

+0

这是限制你可以在一个数据库中的项目数量吗?另外为什么你使用一个数据透视表?枢轴旨在有少量的项目。您的代码最终可能与集合中的图像一样多。您也可能会遇到性能问题,一次加载大量大图像。 – 2010-11-03 11:17:26

回答