samples/TodoApp/TodoApp.iOS/ViewControllers/HomeViewController.cs
/// <summary>
/// Displays the Add new item? dialog.
/// </summary>
/// <returns>A task that returns the added item text when complete.</returns>
Displays the Add new item. dialog.
Displays the Add new item . dialog .
protected static Task<string> ShowAddItemDialogAsync()
        {
            var tcs = new TaskCompletionSource<string>();
            var alert = new UIAlertView
            {
                Title = "Add new item?",
                AlertViewStyle = UIAlertViewStyle.PlainTextInput
            };
            nint okButtonIndex = alert.AddButton("OK");
            nint cancelButtonIndex = alert.AddButton("Cancel");
            alert.CancelButtonIndex = cancelButtonIndex;
            alert.Clicked += (_, e) =>
            {
                if (e.ButtonIndex == okButtonIndex)
                {
                    tcs.TrySetResult(alert.GetTextField(0).Text);
                }
            };
            alert.Show();
            return tcs.Task;
        }
protected static Task < string > ShowAddItemDialogAsync ( ) { var tcs = new TaskCompletionSource < string > ( ) ; var alert = new UIAlertView { Title = " " , AlertViewStyle = UIAlertViewStyle . PlainTextInput } ; nint okButtonIndex = alert . AddButton ( " " ) ; nint cancelButtonIndex = alert . AddButton ( " " ) ; alert . CancelButtonIndex = cancelButtonIndex ; alert . Clicked += ( _ , e ) => { if ( e . ButtonIndex == okButtonIndex ) { tcs . TrySetResult ( alert . GetTextField ( 0 ) . Text ) ; } } ; alert . Show ( ) ; return tcs . Task ; }
Displays the Add new item?
Displays the Add new item?
A task that returns the added item text when complete.
A task that returns the added item text when complete .