Exemple #1
0
        public async Task <List <IPickableItem> > PickMany()
        {
            if (_candidateList.Count == 0)
            {
                return(null);
            }

            if (_candidateList.Count == 1)
            {
                return(_candidateList);
            }

            await QueuedTask.Run(() =>
            {
                _viewModel = new PickerViewModel(_candidateList, false);
            });

            if (_candidateList.Count == 0)
            {
                return(new List <IPickableItem>());
            }

            RunOnUIThread(() => { ShowPickerControl(_viewModel); });

            _viewModel.DisposeOverlays();

            return(_viewModel.SelectedItems.ToList() ?? null);
        }
Exemple #2
0
        public PickerWindow(PickerViewModel vm)
        {
            InitializeComponent();

            if (vm is PickerViewModel pickerViewModel)
            {
                DataContext = pickerViewModel;
            }
        }
Exemple #3
0
        private void ShowPickerControl(PickerViewModel vm)
        {
            PickerWindow window = new PickerWindow(vm);

            ManageWindowLocation(window);
            bool?accepted = window.ShowDialog();

            if (accepted == false)
            {
                vm.SelectedItem = null;
            }
            vm.DisposeOverlays();
        }
Exemple #4
0
        public async Task <IPickableItem> PickSingle()
        {
            if (_candidateList.Count == 0)
            {
                return(null);
            }

            if (_candidateList.Count == 1)
            {
                return(_candidateList.First());
            }

            await QueuedTask.Run(() =>
            {
                _viewModel =
                    new PickerViewModel(_candidateList, true);
            });

            RunOnUIThread(() => { ShowPickerControl(_viewModel); });

            _viewModel.DisposeOverlays();

            return(_viewModel.SelectedItem ?? null);
        }