2014-04-28 100 views
0

有誰知道如何將IStorageItem項目從CameraRoll轉換爲BitmapImage?如何將IStorageItem項目轉換爲BitmapImage

這裏是我的代碼:

 private async void Button_Click(object sender, RoutedEventArgs e) 
     { 

      StorageFolder picturesFolder = KnownFolders.CameraRoll; 

      IReadOnlyList<IStorageItem> itemsList = 
       await picturesFolder.GetItemsAsync(); 

      BitmapImage[] Images = new BitmapImage[itemsList.Count]; 
      int i = 0; 

      foreach (var item in itemsList) 
      { 
       if (item is StorageFolder) 
       { 
       } 
       else 
       { 
        i++; 

        //Images[i].SetSource(item); 

       } 
      } 
     } 

回答

1

在你else塊

else { 
    using (var stream = await item.OpenReadAsync()) 
    { 
     await Images[i].SetSourceAsync(stream); 
    } 
} 
+1

請儘量解釋什麼是問題,當您所提交的解決方案。這可能對未來的讀者有所幫助! – sachinjain024