How to implement a multiple image picker in MAUI from the Photo library

566 views Asked by At

In both MAUI and Xamarin.Forms, the MediaPicker from Essentials doesn't allow to pick multiple images or videos.

In MAUI, we have the FilePicker (from the Microsoft.Maui.Storage namespace) to pick multiple files, It would be a great option but, as far as I tested, it cannot access the Photo library in iOS. You can use it this way:

        var result = await filePicker.PickMultipleAsync(new PickOptions
        {
            PickerTitle = "Pick multiple photos",
            FileTypes = FilePickerFileType.Images
        });

In MAUI and Xamarin Forms, we have the MediaPicker to pick photos from the Photo library, but it doesn't allow to pick multiple photos. You can use it this way:

        var fileResult = await MediaPicker.PickPhotoAsync();

The best option would be if MediaPicker implemented a method to get multiple photos, as already stated in this forum:

https://github.com/dotnet/maui/issues/6903

Something like this:

        var fileResult = await MediaPicker.PickMultiplePhotoAsync();

But as we don't have this method available, in Xamarin Forms I had to discard the MediaPicker option and implement code in native platforms. I took as reference the following post:

https://medium.com/swlh/select-multiple-images-from-the-gallery-in-xamarin-forms-df2e037be572

The bad news is that the package used for iOS in this post (GMImagePicker.Xamarin) is not available for MAUI, so... I'm a bit stuck on this. Any help would be welcome.

0

There are 0 answers