MultipleMediaPickerSample
MultipleMediaPickerSample copied to clipboard
Object reference not set to an instance of an object
public ObservableCollection<MediaFile> Media { get; set; }
public AddPhotoViewModel(INavigation navigation, IMultiMediaPickerService multiMediaPickerService)
{
_multiMediaPickerService = multiMediaPickerService;
BackCommand = new Command(()=> { navigation.PopAsync(); });
AddPhotoCommand = new Command(async () =>
{
var action = await Application.Current.MainPage.DisplayActionSheet("Select photo", "Cancel", null, "Take a Photo", "Open Gallery");
WriteLine("Action " + action);
if (action == "Take a Photo")
{
TakeAPhoto();
}
if (action == "Open Gallery")
{
//OpenGallery();
var hasPermission = await CheckPermissionsAsync();
if (hasPermission)
{
Media = new ObservableCollection<MediaFile>();
await _multiMediaPickerService.PickPhotosAsync();
}
}
});
}