Esempio n. 1
0
        private async Task <double> OpenSliderInputAlertDialog()
        {
            // create the TextInputView
            var inputView = new SlidableInputView(
                "How much would you rate it?", 0, 10,
                "Save", "Cancel", "Ops! You can't leave with an empty value!");

            // create the Transparent Popup Page
            // of type string since we need a string return
            var popup = new InputAlertDialogBase <double>(inputView);

            // subscribe to the TextInputView's Button click event
            inputView.SaveButtonEventHandler +=
                (sender, obj) =>
            {
                if (((SlidableInputView)sender).SliderInputResult > 0)
                {
                    ((SlidableInputView)sender).IsValidationLabelVisible = false;
                    popup.PageClosedTaskCompletionSource.SetResult(((SlidableInputView)sender).SliderInputResult);
                }
                else
                {
                    ((SlidableInputView)sender).IsValidationLabelVisible = true;
                }
            };

            // subscribe to the TextInputView's Button click event
            inputView.CancelButtonEventHandler +=
                (sender, obj) =>
            {
                popup.PageClosedTaskCompletionSource.SetResult(0);
            };

            // Push the page to Navigation Stack
            await PopupNavigation.PushAsync(popup);

            // await for the user to enter the text input
            var result = await popup.PageClosedTask;

            // Pop the page from Navigation Stack
            await PopupNavigation.PopAsync();

            // return user inserted text value
            return(result);
        }
Esempio n. 2
0
        public async Task <double> OpenSliderInputAlertDialog(string titleText, double minValue, double maxValue, string saveButtonText,
                                                              string cancelButtonText, string validationText)
        {
            // create the TextInputView
            var inputView = new SlidableInputView(
                "How much would you rate it?", 0, 10,
                "Save", "Cancel", "Ops! You can't leave with an empty value!");

            // create the Transparent Popup Page
            // of type string since we need a string return
            var popup = new InputAlertDialogBase <double>(inputView);

            // subscribe to the TextInputView's Button click event
            inputView.SaveButtonEventHandler +=
                (sender, obj) =>
            {
                if (((SlidableInputView)sender).SliderInputResult > 0)
                {
                    ((SlidableInputView)sender).IsValidationLabelVisible = false;
                    popup.PageClosedTaskCompletionSource.SetResult(((SlidableInputView)sender).SliderInputResult);
                }
                else
                {
                    ((SlidableInputView)sender).IsValidationLabelVisible = true;
                }
            };

            // subscribe to the TextInputView's Button click event
            inputView.CancelButtonEventHandler +=
                (sender, obj) =>
            {
                popup.PageClosedTaskCompletionSource.SetResult(0);
            };

            // return user inserted text value
            return(await Navigate(popup));
        }