public static async Task <object> ShowSelectChoiceAsync(string title, IList choices, string choiceBindingName = null, string confirmingText = "Ok", string dismissiveText = "Cancel", MaterialConfirmationDialogConfiguration configuration = null)
        {
            var radioButtonGroup = new MaterialRadioButtonGroup
            {
                HorizontalSpacing  = 20,
                ChoicesBindingName = choiceBindingName
            };

            radioButtonGroup.Choices = choices ?? throw new ArgumentNullException(nameof(choices));

            var dialog = new MaterialConfirmationDialog(configuration)
            {
                InputTaskCompletionSource = new TaskCompletionSource <object>(),
                _controlGroup             = radioButtonGroup
            };

            if (dialog._preferredConfig != null)
            {
                dialog._controlGroup.SelectedColor   = dialog._preferredConfig.ControlSelectedColor;
                dialog._controlGroup.UnselectedColor = dialog._preferredConfig.ControlUnselectedColor;
                dialog._controlGroup.FontFamily      = dialog._preferredConfig.TextFontFamily;
                dialog._controlGroup.TextColor       = dialog._preferredConfig.TextColor;
            }

            dialog._controlGroup.ShouldShowScrollbar = true;
            dialog.DialogTitle.Text         = !string.IsNullOrEmpty(title) ? title : throw new ArgumentNullException(nameof(title));
            dialog.PositiveButton.IsEnabled = false;
            dialog.PositiveButton.Text      = confirmingText.ToUpper();
            dialog.NegativeButton.Text      = dismissiveText.ToUpper();
            dialog.container.Content        = dialog._controlGroup;
            await dialog.ShowAsync();

            return(await dialog.InputTaskCompletionSource.Task);
        }
示例#2
0
        public static async Task <object> ShowSelectChoicesAsync(string title, IList <string> choices, MaterialConfirmationDialogConfiguration configuration)
        {
            var dialog = new MaterialConfirmationDialog(configuration)
            {
                InputTaskCompletionSource = new TaskCompletionSource <object>()
            };

            dialog._checkboxGroup = new MaterialCheckboxGroup
            {
                HorizontalSpacing = 20,
                Choices           = choices ?? throw new ArgumentNullException(nameof(choices))
            };

            if (dialog._preferredConfig != null)
            {
                dialog._checkboxGroup.SelectedColor   = dialog._preferredConfig.ControlSelectedColor;
                dialog._checkboxGroup.UnselectedColor = dialog._preferredConfig.ControlUnselectedColor;
                dialog._checkboxGroup.FontFamily      = dialog._preferredConfig.TextFontFamily;
                dialog._checkboxGroup.TextColor       = dialog._preferredConfig.TextColor;
            }

            dialog._checkboxGroup.ShouldShowScrollbar = true;
            dialog._isMultiChoice    = true;
            dialog.DialogTitle.Text  = !string.IsNullOrEmpty(title) ? title : throw new ArgumentNullException(nameof(title));
            dialog.container.Content = dialog._checkboxGroup;
            await dialog.ShowAsync();

            return(await dialog.InputTaskCompletionSource.Task);
        }
示例#3
0
        public static async Task <object> ShowSelectChoiceAsync(string title, IList <string> choices, int selectedIndex, MaterialConfirmationDialogConfiguration configuration)
        {
            var dialog = new MaterialConfirmationDialog(configuration)
            {
                InputTaskCompletionSource = new TaskCompletionSource <object>()
            };

            dialog._radioButtonGroup = new MaterialRadioButtonGroup
            {
                HorizontalSpacing                                   = 20,
                Choices                                             = choices ?? throw new ArgumentNullException(nameof(choices)),
                                                      SelectedIndex = selectedIndex
            };

            if (dialog._preferredConfig != null)
            {
                dialog._radioButtonGroup.SelectedColor   = dialog._preferredConfig.ControlSelectedColor;
                dialog._radioButtonGroup.UnselectedColor = dialog._preferredConfig.ControlUnselectedColor;
                dialog._radioButtonGroup.FontFamily      = dialog._preferredConfig.TextFontFamily;
                dialog._radioButtonGroup.TextColor       = dialog._preferredConfig.TextColor;
            }

            dialog.DialogTitle.Text         = !string.IsNullOrEmpty(title) ? title : throw new ArgumentNullException(nameof(title));
            dialog.container.Content        = dialog._radioButtonGroup;
            dialog.PositiveButton.IsEnabled = true;
            await dialog.ShowAsync();

            return(await dialog.InputTaskCompletionSource.Task);
        }