private async Task <string> OpenSelectableInputAlertDialog() { // create the TextInputView var inputView = new SelectableInputView( "How's your day mate?", new List <string>() { "Awesome!", "Great!", "Cool!", "Good!", "Not Bad!", "Meh!" }, "Save", "Cancel", "Ops! You can't leave without a selection!"); // create the Transparent Popup Page // of type string since we need a string return var popup = new InputAlertDialogBase <string>(inputView); // subscribe to the TextInputView's Button click event inputView.SaveButtonEventHandler += (sender, obj) => { if (!string.IsNullOrEmpty(((SelectableInputView)sender).SelectionResult)) { ((SelectableInputView)sender).IsValidationLabelVisible = false; popup.PageClosedTaskCompletionSource.SetResult(((SelectableInputView)sender).SelectionResult); } else { ((SelectableInputView)sender).IsValidationLabelVisible = true; } }; // subscribe to the TextInputView's Button click event inputView.CancelButtonEventHandler += (sender, obj) => { popup.PageClosedTaskCompletionSource.SetResult(null); }; // 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); }
public async Task <string> OpenSelectableInputAlertDialog(string titleText, IList <string> selectiondataSource, string saveButtonText, string cancelButtonText, string validationText) { // create the TextInputView var inputView = new SelectableInputView( "How's your day mate?", new List <string>() { "Awesome!", "Great!", "Cool!", "Good!", "Not Bad!", "Meh!" }, "Save", "Cancel", "Ops! You can't leave without a selection!"); // create the Transparent Popup Page // of type string since we need a string return var popup = new InputAlertDialogBase <string>(inputView); // subscribe to the TextInputView's Button click event inputView.SaveButtonEventHandler += (sender, obj) => { if (!string.IsNullOrEmpty(((SelectableInputView)sender).SelectionResult)) { ((SelectableInputView)sender).IsValidationLabelVisible = false; popup.PageClosedTaskCompletionSource.SetResult(((SelectableInputView)sender).SelectionResult); } else { ((SelectableInputView)sender).IsValidationLabelVisible = true; } }; // subscribe to the TextInputView's Button click event inputView.CancelButtonEventHandler += (sender, obj) => { popup.PageClosedTaskCompletionSource.SetResult(null); }; // return user inserted text value return(await Navigate(popup)); }