AcManager.Controls.Dialogs.Prompt.ShowAsync C# (CSharp) Method

ShowAsync() public method

public ShowAsync ( CancellationToken cancellation ) : Task
cancellation System.Threading.CancellationToken
return Task
        public async Task ShowAsync(CancellationToken cancellation) {
            await Application.Current.Dispatcher.InvokeAsync(ShowDialog, DispatcherPriority.Normal, cancellation).Task;
            if (cancellation.IsCancellationRequested) Close();
        }

Same methods

Prompt::ShowAsync ( string description, string title, string defaultValue = "", string watermark = null, string toolTip = null, bool multiline = false, bool passwordMode = false, bool required = false, int maxLength = -1, IEnumerable suggestions = null, CancellationToken cancellation = default(CancellationToken) ) : Task

Usage Example

Example #1
0
        public static async Task <string> ShowAsync(string description, string title, string defaultValue = "", string watermark = null, string toolTip = null,
                                                    bool multiline = false, bool passwordMode = false, bool required = false, int maxLength = -1, IEnumerable <string> suggestions = null,
                                                    CancellationToken cancellation = default(CancellationToken))
        {
            if (passwordMode && suggestions != null)
            {
                throw new ArgumentException(@"Can’t have suggestions with password mode");
            }
            if (passwordMode && multiline)
            {
                throw new ArgumentException(@"Can’t use multiline input area with password mode");
            }
            if (suggestions != null && multiline)
            {
                throw new ArgumentException(@"Can’t use multiline input area with suggestions");
            }

            var dialog = new Prompt(title, description, defaultValue, watermark, toolTip, multiline, passwordMode, required, maxLength, suggestions);

            try {
                await dialog.ShowAsync(cancellation);
            } catch (TaskCanceledException) {
                return(null);
            }

            var result = dialog.Result;

            if (maxLength != -1 && result?.Length > maxLength)
            {
                result = result.Substring(0, maxLength);
            }
            return(result);
        }
All Usage Examples Of AcManager.Controls.Dialogs.Prompt::ShowAsync