public PhotosViewModel(IMediaAlbum album) { album.GetAllMediaFilesAsync() .ContinueWith((arg) => { Photos = arg.Result.Select(a => new PhotoItem(a)).ToArray(); }); }
public Task <IMediaAlbum> CreateAlbum(string title) { return(Task.Run(() => { IMediaAlbum album = null; string id = null; if (PHPhotoLibrary.SharedPhotoLibrary.PerformChangesAndWait(() => { var request = PHAssetCollectionChangeRequest.CreateAssetCollection(title); id = request.PlaceholderForCreatedAssetCollection.LocalIdentifier; }, out var error)) { var col = (PHAssetCollection)PHAssetCollection.FetchAssetCollections(new[] { id }, null).First(); album = new MediaAlbum(col); } return album; })); }
public Photos(IMediaAlbum album) { InitializeComponent(); BindingContext = new PhotosViewModel(album); }