Esempio n. 1
0
        /// <inheritdoc />
        public PickerDialogViewModel(
            PickerDialog <PickerDialogViewModel> dialog,
            IDialogPickerViewModel source)
        {
            _source = source ?? throw new ArgumentNullException(nameof(source));
            _dialog = dialog ?? throw new ArgumentNullException(nameof(dialog));

            _source.WeakSubscribe(
                nameof(IDialogPickerViewModel.ItemsChanged),
                OnItemsChanged);
        }
Esempio n. 2
0
        public Task <bool> ShowPicker(IDialogPickerViewModel source)
        {
            var tcs             = new TaskCompletionSource <bool>();
            var dialog          = new PickerDialog <PickerDialogViewModel>();
            var pickerViewModel = new PickerDialogViewModel(dialog, source);

            dialog
            .Show(
                source.Title,
                callback: v => tcs.TrySetResult(true),
                pickerViewModel,
                pickerCallback: v =>
            {
                foreach (var selectedItem in source.SelectedItems)
                {
                    v.Select(selectedItem.Row, selectedItem.Component, animated: false);
                }
            },
                cancelCallback: () => tcs.TrySetResult(false));

            return(tcs.Task);
        }