2011-04-04 47 views
0

打開多個圖片這是我的代碼:不能在WPF

foreach (Database.Photo photo in eventPhotos) 
     { 
      Image img = new Image(); 
      img.Height = 100; 
      img.Width = 80; 
      img.Focusable = true; 
      img.MouseDown += new MouseButtonEventHandler(img_MouseDown); 
      string littleString = photo.PhotoUrl; 
      littleString = littleString.Replace(".jpg", "t.jpg"); 
      BitmapImage bi = new BitmapImage(); 
      bi.BeginInit(); 
      bi.UriSource = new Uri(littleString, UriKind.Absolute); 
      bi.EndInit(); 
      img.Source = bi; 
      imagesEvent1.Children.Add(img); 
     } 

但並不是所有的圖像加載:

enter image description here

在這個時候

,№3,5未加載圖像,在下一次其他圖像不加載。

+2

您是否從互聯網上獲取圖像?下載可能失敗。 – RandomEngy 2011-04-04 16:51:27

+0

是的,來自互聯網。互聯網:2Mb/s – GLeBaTi 2011-04-04 16:54:33

+0

1圖像的大小:9,4 KB – GLeBaTi 2011-04-04 16:55:49

回答

2

圖像下載可能失敗。嘗試處理Image控件上的ImageFailed事件並查看是否觸發。