コード例 #1
0
        public static async Task <object> ShowSelectChoiceAsync(string title, IList <string> choices, string confirmingText = "Ok", string dismissiveText = "Cancel", MaterialConfirmationDialogConfiguration configuration = null, bool closeOnSelection = false)
        {
            using var dialog = new MaterialConfirmationDialog(configuration)
                  {
                      InputTaskCompletionSource = new TaskCompletionSource <object>(),
                      _radioButtonGroup         = new MaterialRadioButtonGroup
                      {
                          HorizontalSpacing = 20,
                          Choices           = choices ?? throw new ArgumentNullException(nameof(choices)),
                      }
                  };

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

            if (closeOnSelection)
            {
                dialog.PositiveButton.IsVisible = false;
                dialog._radioButtonGroup.SelectedIndexChanged += (sender, args) => dialog.PositiveButton_Clicked(sender, EventArgs.Empty);
            }

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

            return(await dialog.InputTaskCompletionSource.Task.ConfigureAwait(false));
        }
コード例 #2
0
        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);
        }
コード例 #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>(),
                _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._radioButtonGroup.ShouldShowScrollbar = true;
            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);
        }
コード例 #4
0
        async void btnRadiobuttonClicked(object sender, EventArgs args)
        {
            var choices = new string[]
            {
                "É BOT",
                "É Magia",
                "Não Dorme é um Vampiro",
                "Só Deus Sabe"
            };

            var view = new MaterialRadioButtonGroup()
            {
                Choices = choices
            };

            bool?wasConfirmed = await MaterialDialog.Instance.ShowCustomContentAsync(view, "O Renato Groffe é onipresente?", "Duvida");
        }
コード例 #5
0
        private async void MaterialButton_Clicked_1(object sender, EventArgs e)
        {
            var choices = new string[]
            {
                "Biology",
                "Psychology",
                "Phsyics",
                "Chemistry"
            };

            var view = new MaterialRadioButtonGroup()
            {
                Choices = choices
            };

            bool?wasConfirmed = await MaterialDialog.Instance.ShowCustomContentAsync(view, "What field of science is considered as the study of life?", "Question 1", "OK", "Cancel");

            Debug.WriteLine(wasConfirmed);
        }