private async void FileOpenPicker_Continuation(StorageFile file)
 {
     if (file != null)
     {
         var destFile = await file.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder, file.Name, NameCollisionOption.ReplaceExisting);
         var userPhoto = new UserPhotoDataItem() { Title = destFile.Name};
         userPhoto.SetImage(destFile.Path);
         item.UserPhotos.Add(userPhoto);
     }
 }
Пример #2
0
        private async void btnPhoto_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.ViewMode = PickerViewMode.Thumbnail;
            openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".png");

            StorageFile file = await openPicker.PickSingleFileAsync();

            if (file != null)
            {
                var destFile = await file.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder, file.Name, NameCollisionOption.ReplaceExisting);
                var userPhoto = new UserPhotoDataItem() { Title = destFile.Name};
                userPhoto.SetImage(destFile.Path);
                item.UserPhotos.Add(userPhoto);
            }
        }