/// <summary> /// Shows the dialog on the specified View Controller /// </summary> /// <returns>The dialog async.</returns> /// <param name="vc">The view controlller</param> /// <param name="title">Title.</param> /// <param name="message">Message.</param> /// <param name="items">Items.</param> /// <param name="selectedItem">Selected item.</param> /// <param name="effectStyle">Effect style.</param> public static Task <String> ShowDialogAsync(UIViewController vc, String title, String message, List <String> items, String selectedItem = null, UIBlurEffectStyle effectStyle = UIBlurEffectStyle.ExtraLight) { var tcs = new TaskCompletionSource <String> (); new NSObject().BeginInvokeOnMainThread(() => { var dialog = new XamSimplePickerDialog(items) { Title = title, Message = message, BlurEffectStyle = effectStyle, ConstantUpdates = false, }; if (!String.IsNullOrWhiteSpace(selectedItem)) { dialog.SelectedItem = selectedItem; } dialog.OnCancel += (object sender, EventArgs e) => { tcs.SetResult(null); }; dialog.OnSelectedItemChanged += (object s, string e) => { tcs.SetResult(dialog.SelectedItem); }; dialog.Show(vc); }); return(tcs.Task); }
/// <summary> /// Shows the dialog on the specified view controller /// </summary> /// <returns>The dialog async.</returns> /// <param name="view">View.</param> /// <param name="title">Title.</param> /// <param name="message">Message.</param> /// <param name="items">Items.</param> /// <param name="selectedItem">Selected item.</param> /// <param name="effectStyle">Effect style.</param> public static Task <uint?> ShowDialogAsync(UIView view, String title, String message, List <String> items, uint selectedIndex = 0, UIBlurEffectStyle effectStyle = UIBlurEffectStyle.ExtraLight) { var tcs = new TaskCompletionSource <uint?> (); new NSObject().BeginInvokeOnMainThread(() => { var dialog = new XamSimplePickerDialog(items) { Title = title, Message = message, ConstantUpdates = false, }; dialog.SelectedIndex = selectedIndex; dialog.OnCancel += (object sender, EventArgs e) => { tcs.SetResult(null); }; dialog.OnSelectedIndexChanged += (object s, uint e) => { tcs.SetResult(dialog.SelectedIndex); }; dialog.Show(view); }); return(tcs.Task); }
partial void ShowSimplePicker (UIButton sender) { var dialog = new XamSimplePickerDialog(new List<String>(){"Ringo","John","Paul", "George"}) { Title = "Favorite Beatle", Message = "Pick your favorite beatle", BlurEffectStyle = UIBlurEffectStyle.ExtraLight, CancelButtonText = "Cancel", ConstantUpdates = false, }; dialog.OnSelectedItemChanged += (object s, string e) => { Console.WriteLine(e); }; dialog.SelectedItem = "John"; dialog.Show(); // Static methods // var result = await XamSimplePickerDialog.ShowDialogAsync("Who are you?","Select your name", new List<String>(){"Dave","Rob","Jamie"}, "Rob"); // Console.WriteLine(result); }
/// <summary> /// Shows the dialog on the specified view controller /// </summary> /// <returns>The dialog async.</returns> /// <param name="view">View.</param> /// <param name="title">Title.</param> /// <param name="message">Message.</param> /// <param name="items">Items.</param> /// <param name="selectedItem">Selected item.</param> /// <param name="effectStyle">Effect style.</param> public static Task<String> ShowDialogAsync(UIView view, String title, String message, List<String> items, String selectedItem = null, UIBlurEffectStyle effectStyle = UIBlurEffectStyle.ExtraLight) { var tcs = new TaskCompletionSource<String> (); new NSObject ().BeginInvokeOnMainThread (() => { var dialog = new XamSimplePickerDialog(items) { Title = title, Message = message, BlurEffectStyle = effectStyle, ConstantUpdates = false, }; if (!String.IsNullOrWhiteSpace(selectedItem)) dialog.SelectedItem = selectedItem; dialog.OnCancel += (object sender, EventArgs e) => { tcs.SetResult(null); }; dialog.OnSelectedItemChanged += (object s, string e) => { tcs.SetResult(dialog.SelectedItem); }; dialog.Show(view); }); return tcs.Task; }