MultipleMediaPickerSample icon indicating copy to clipboard operation
MultipleMediaPickerSample copied to clipboard

Object reference not set to an instance of an object

Open nguyenthanhliemfc opened this issue 5 years ago • 0 comments

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();
                    }
                }
                
            });
        }

nguyenthanhliemfc avatar Jun 26 '19 02:06 nguyenthanhliemfc