Windows Phone 8.1에서 내 그림 앨범의 이미지를 선택하고 싶습니다. 이를 위해 나는 당신도 당신이 필요한 페이지에 OnActivated 이벤트를 처리 할 수 있다고 생각이 코드를 사용하지만 오류Windows Phone 8.1의 파일 선택기
private async void gallery_Tapped(object sender, TappedRoutedEventArgs e)
{
FileOpenPicker opener = new FileOpenPicker();
opener.ViewMode = PickerViewMode.Thumbnail;
opener.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
opener.FileTypeFilter.Add(".jpg");
opener.FileTypeFilter.Add(".jpeg");
opener.FileTypeFilter.Add(".png");
StorageFile file = await opener.PickSingleFileAsync();
if (file != null)
{
// We've now got the file. Do something with it.
var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
var bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
await bitmapImage.SetSourceAsync(stream);
var decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream);
MyImage.Source=bitmapImage;
}
else
{
//OutputTextBlock.Text = "The operation may have been cancelled.";
}
}
오류
당신이 [PickSingleFileAndContinue] 사용하지 말아야합니다 (http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.pickers.fileopenpicker.picksinglefileandcontinue. aspx?)? –
Ulugbek이 말했듯이 - Windows Phone을 목표로 삼고 있으며 이러한 메서드 (* PickSingleFileAsync() *)를 사용할 수 없으므로 파일을 선택하는 동안 앱이 종료 될 수 있습니다. 위의 방법을 사용해야합니다. 자세한 내용과 좋은 예를 보려면 [여기 MSDN] (http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn614994.aspx)을 참조하십시오. – Romasz
네, 그게 맞지만 그 무효를 반환하는 선택한 파일을 어떻게 처리할까요? –