2013-06-23 17 views
0

我想添加圖像,我從我的攝像頭到gridview,但每次我得到異常。我有單獨的頁面從網絡攝像頭製作圖片,之後,我將圖像傳遞到其他頁面。以下是代碼片段:添加圖像到gridview窗口的錯誤8商店的應用程序

C#

protected override void OnNavigatedTo(NavigationEventArgs e) 
{ 
    //If navigated from PhotoCapturePage 
    if (m_ToBeNavigatedPageType == typeof(PhotoCapturePage)) 
    { 
     if (e.Parameter == null) 
     { 
      return; 
     } 
     Image img = new Image(); 
     img.Width = 64; 
     img.Height = 64; 
     img.Source = new BitmapImage(new Uri(e.Parameter.ToString())); 

     IncidentPictures.Add(img); 

     IncidentPictureGrid.Items.Add(img); 
    } 
} 

XAML:

<GridView ItemsSource="{Binding IncidentPictures}" Name="IncidentPictureGrid" Width="350"></GridView> 

進行IncidentPictureGrid.Items.Add(img)每一次,我收到災難性的失敗(Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))例外。 有沒有人有建議?

由於提前, Miroslawas

回答

0

爲什麼你的圖像添加到收藏Grid.Items當你將它添加到收藏IncidentPictures過?

您已經將GridView的ItemsSource綁定到集合。也許這會導致錯誤...刪除IncidentPictureGrid.Items.Add並確保IncidentPictures是一個ObservableCollection。

+0

它沒有任何區別。 –

+0

好的,所以執行IncidentPictureGrid.Items.Add(img)時發生錯誤。如果你刪除該行,它發生IncidentPictures.Add(img)? – Alexander

相關問題