我正在尝试将从我的网络摄像头获得的图像添加到 gridview 但是每次我遇到异常时。我有单独的页面从网络摄像头制作图片,然后,我将图像完整路径传递到其他页面。以下是代码片段:
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