示例#1
0
        private async void OnPickImagesClick(object sender, EventArgs args)
        {
            var results = await MediaGallery.PickAsync(3, MediaFileType.Image, MediaFileType.Video);

            if (results?.Files == null)
            {
                return;
            }

            foreach (var media in results.Files)
            {
                var fileName    = media.NameWithoutExtension;
                var extension   = media.Extension;
                var contentType = media.ContentType;

                await DisplayAlert(fileName, $"Extension: {extension}, Content-type: {contentType}", "OK");
            }
        }
示例#2
0
        async Task Pick(params MediaFileType[] types)
        {
            try
            {
                if (SelectedItems?.Count() > 0)
                {
                    foreach (var item in SelectedItems)
                    {
                        item.Dispose();
                    }
                }

                var result = await MediaGallery.PickAsync(SelectionLimit, types);

                SelectedItems = result?.Files?.ToArray();
            }
            catch (Exception ex)
            {
                await DisplayAlertAsync(ex.Message);
            }
        }