public async Task <string> GetTextAsync(string title, string placeholder, string defaultText = "", Func <string, bool> validater = null) { if (validater == null) { validater = (_) => true; } var context = new TextInputDialogContext(title, placeholder, defaultText, validater); var dialog = new TextInputDialog() { DataContext = context }; var result = await dialog.ShowAsync(); // 仮想入力キーボードを閉じる Windows.UI.ViewManagement.InputPane.GetForCurrentView().TryHide(); if (result == Windows.UI.Xaml.Controls.ContentDialogResult.Primary) { return(context.GetValidText()); } else { return(null); } }
public async Task <string?> ShowInput(InputDialogData data) { var dialog = new TextInputDialog(data); var showResult = await dialog.ShowAsync(); if (showResult == ContentDialogResult.Primary) { return(dialog.Data.InputDefaultValue); } return(null); }
public static async Task <string> Prompt(this IDialogService dialogService, string title, string initialValue = null) { KeyEventsAgregator.IsDisabled = true; var dialog = new TextInputDialog { Text = initialValue, Title = title, PrimaryButtonText = "Ok" }; var result = await dialog.ShowAsync(); KeyEventsAgregator.IsDisabled = false; return(result == Windows.UI.Xaml.Controls.ContentDialogResult.Primary ? dialog.Text : null); }
public async void SaveChatAsImageWithName() { TextInputDialog d = new TextInputDialog() { Title = "Save Snapshot As..", PlaceholderText = "Enter a name to save the snapshot" }; await d.ShowAsync(); var saved = await SaveChatAsImage(Utils.NormalizeFileName(d.Text)); if (!saved) { await Utils.ShowDialogAsync("Unable to save the snapshot!"); } else { await Utils.ShowDialogAsync($"The snapshot is saved in your Pictures/{ANACHATFLOWS_FOLDER} folder"); } }