public void AskQuestions(string title, Shared.Models.Question question, Action <int> completed) { App.CurrentActivity.RunOnUiThread(() => new AlertDialog.Builder(App.CurrentActivity) .SetTitle(question.Text) .SetItems(question.Answers.Select(a => a.Text).ToArray(), (sender, args) => { if (completed != null) { completed(args.Which); } }) .SetNegativeButton("Cancel", delegate { }) .Create() .Show()); }
public void AskQuestions(string title, Shared.Models.Question question, Action <int> completed) { Utils.EnsureInvokedOnMainThread(() => { var alert = new UIAlertView(title, question.Text, null, "Cancel", question.Answers.Select(s => s.Text).ToArray()); alert.Dismissed += (sender2, args) => { if (args.ButtonIndex == 0) { return; } completed((int)args.ButtonIndex - 1); //subtract 1 becuase of cancel button }; alert.Show(); }); }
public void AskQuestions(string title, Shared.Models.Question question, Action <int> completed) { Deployment.Current.Dispatcher.BeginInvoke(() => { var messagePrompt = new MessagePrompt { Title = title, IsCancelVisible = true, IsAppBarVisible = false }; var listBox = new ListBox() { MaxWidth = 400, MaxHeight = 320 }; listBox.ItemsSource = question.Answers.Select(q => q.Text).ToArray(); listBox.ItemTemplate = Application.Current.Resources["AnswerItemTemplate"] as DataTemplate; listBox.SelectionMode = SelectionMode.Single; messagePrompt.Body = listBox; messagePrompt.Completed += (sender, e) => { if (e.PopUpResult != PopUpResult.Ok || listBox.SelectedIndex < 0) { return; } if (completed != null) { completed(listBox.SelectedIndex); } }; messagePrompt.Show(); }); }