2010-11-03 99 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

回答