我试图在windows phone listview中显示捕获的图像,以便使用后台代理上传。但是当cameracapturedtask完成时,应用程序将在app.xaml.cs中停用。当我从Gallery上传图像时,同样的功能正常工作。我在下面提供了我的代码。如果有任何解决方案,请提供帮助。
private void Camera_Click(object sender, RoutedEventArgs e)
{
cmb.Dismiss();
CameraCaptureTask cameraCapture = new CameraCaptureTask();
cameraCapture.Completed += new EventHandler<PhotoResult>(cameraCaptureTask_Completed);
cameraCapture.Show();
}
private void cameraCaptureTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
string filename = e.OriginalFileName;
var listSplit = filename.Split('\\');
int i = listSplit.Length;
string name = listSplit[i - 1];
PhotoResult photoResult = e;
j = 1;
//sendImgRequest(name, e);
BitmapImage bmp = new BitmapImage();
bmp.SetSource(e.ChosenPhoto);
arrfilename.Add(filename);
//arrimg.Add(bmp);
arrstream.Add(e.ChosenPhoto);
arrtext.Add("Photo");
using (var isostore = IsolatedStorageFile.GetUserStoreForApplication())
{
var wb = new WriteableBitmap(bmp);
using (var isoFileStream = isostore.CreateFile(name))
wb.SaveJpeg(isoFileStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
}
newimgdata.Add(new imgdata { image = bmp, text = "Photo", filename = name });
lstbox.ItemsSource = newimgdata;
}
}