Skip to content

Object reference not set to an instance of an object #3

@nguyenthanhliemfc

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions