コード例 #1
0
 public PhotosViewModel(IMediaAlbum album)
 {
     album.GetAllMediaFilesAsync()
     .ContinueWith((arg) =>
     {
         Photos = arg.Result.Select(a => new PhotoItem(a)).ToArray();
     });
 }
コード例 #2
0
        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;
            }));
        }
コード例 #3
0
        public Photos(IMediaAlbum album)
        {
            InitializeComponent();

            BindingContext = new PhotosViewModel(album);
        }