Firstly for select multiple images in Xamarin Forms, you should do a dependency service for each platform.
In Android use:
.PutExtra (Intent.ExtraAllowMultiple, true);
Ex:
[assembly: Xamarin.Forms.Dependency (typeof (MediaService))]
namespace MyProject
{
public class MediaService : Java.Lang.Object, IMediaService
{
public MediaService ()
{
}
public void OpenGallery()
{
Toast.MakeText (Xamarin.Forms.Forms.Context, "Select max 20 images", ToastLength.Long).Show ();
var imageIntent = new Intent(
Intent.ActionPick);
imageIntent.SetType ("image/*");
imageIntent.PutExtra (Intent.ExtraAllowMultiple, true);
imageIntent.SetAction (Intent.ActionGetContent);
((Activity)Forms.Context).StartActivityForResult(
Intent.CreateChooser (imageIntent, "Select photo"), 0);
}
}
}
In IOS:
Install this control: ELCImagePicker
And:
[assembly: Xamarin.Forms.Dependency (typeof (MediaService))]
namespace MyProject
{
public class MediaService: IMediaService, IMessanger
{
public MediaService ()
{
}
public void OpenGallery()
{
var picker = ELCImagePickerViewController.Instance;
picker.MaximumImagesCount = 15;
picker.Completion.ContinueWith (t => {
picker.BeginInvokeOnMainThread(()=>
{
//dismiss the picker
picker.DismissViewController(true,null);
if (t.IsCanceled || t.Exception != null) {
} else {
Util.File.Path = new List<string>();
var items = t.Result as List<AssetResult>;
foreach (var item in items) {
Util.File.Path.Add (item.Path);
}
MessagingCenter.Send<IMessanger> (this, "PostProject");
}
});
});
var topController = UIApplication.SharedApplication.KeyWindow.RootViewController;
while (topController.PresentedViewController != null) {
topController = topController.PresentedViewController;
}
topController.PresentViewController (picker, true, null);
}
}
}