private async void AddStockButton_OnTapped(object sender, TappedRoutedEventArgs e) { var dialog = new InputDialog { AcceptButton = "Continue", CancelButton = "Cancel", IsLightDismissEnabled = true }; string result = await dialog.ShowAsync("Subscribe to a stock symbol", "Please enter a stock symbol and a purchasing quantity. Example: MSFT or MSFT,1000", "Continue"); if ((null != result) && !string.IsNullOrWhiteSpace(dialog.InputText)) { string[] parts = dialog.InputText.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string symbolPart = parts.ElementAtOrDefault(0); if (!string.IsNullOrWhiteSpace(symbolPart)) { symbolPart = symbolPart.Trim(); string quantityPart = parts.ElementAtOrDefault(1); if (!string.IsNullOrWhiteSpace(quantityPart)) { quantityPart = quantityPart.Trim(); } int quantity; if (!int.TryParse(quantityPart, out quantity)) { quantity = 50; } this.Presenter.OnAddStock(symbolPart.ToUpperInvariant(), quantity); } } }
private async void RegularStyleTest(object sender, RoutedEventArgs e) { var dialog = new InputDialog(); var result = await dialog.ShowAsync("This is the title", "This is the content/message", "Option 1", "Option 2", "Option 3"); var content = string.Format( "Text: {0}, Button: {1}", dialog.InputText ?? "", result ?? ""); await new MessageDialog(content, "Result").ShowAsync(); }
public Activities() { DispatcherHelper.Initialize(); // Set up the Caption dialog. This will be re-used frequently CaptionDialog = new InputDialog(); CaptionDialog.BackgroundStripeBrush = AvocadoGreen; CaptionDialog.Background = AvocadoGreen; CaptionDialog.BorderBrush = new SolidColorBrush(Colors.Transparent); CaptionDialog.AcceptButton = PostButtonText; CaptionDialog.CancelButton = CancelPostButtonText; }
private async void CustomStyleTest(object sender, RoutedEventArgs e) { var dialog = new InputDialog(); dialog.AcceptButton = "Option 3 (Accept)"; dialog.CancelButton = "Option 2 (Cancel)"; // For some reason it has to be defined here - does not work when set using a style setter. dialog.ButtonsPanelOrientation = Orientation.Vertical; dialog.Style = (Style)this.Resources["CustomInputDialogStyle"]; var result = await dialog.ShowAsync("This is the title", "This is the content/message", "Option 1", "Option 2 (Cancel)", "Option 3 (Accept)"); var content = string.Format( "Text: {0}, Button: {1}", dialog.InputText ?? "", result ?? ""); #pragma warning disable 4014 new MessageDialog(content, "Result").ShowAsync(); #pragma warning restore 4014 }
public async static Task<string> AskForInput(string title, string text, bool allowCancel=true) { InputDialog dialog = new InputDialog(); /*dialog.Background = Colors.BackgroundColor; dialog.Foreground = Colors.TextColor;*/ dialog.ButtonStyle = new Button().Style; string response; if (allowCancel) { response = await dialog.ShowAsync(title, text, "OK", "Cancel"); } else { response = await dialog.ShowAsync(title, text, "OK"); } if (response == "OK") return dialog.InputText; else return null; }
public async Task<InputResponse> InputAsync(string message, string placeholder = null, string title = null, string okButton = "OK", string cancelButton = "Cancel", string initialText = null) { var box = new InputDialog { InputText = initialText ?? string.Empty }; var result = await box.ShowAsync(title ?? string.Empty, message, okButton, cancelButton); return new InputResponse() {Text = box.InputText, Ok = result == okButton}; }
private static async void InputDialogAndStringIOTest() { var dialog = new InputDialog(); await dialog.ShowAsync("Title", "Text", "OK", "Cancel"); await new MessageDialog(dialog.InputText, "WinRTXamlToolkit.Sample").ShowAsync(); await "ABC".WriteToFile("abc.txt", KnownFolders.DocumentsLibrary); await "DEF".WriteToFile("abc.txt", KnownFolders.DocumentsLibrary); await "ABC2".WriteToFile("abc2.txt", KnownFolders.DocumentsLibrary); await new MessageDialog("Test files written", "WinRTXamlToolkit.Sample").ShowAsync(); var abc = await StringIOExtensions.ReadFromFile("abc.txt", KnownFolders.DocumentsLibrary); await new MessageDialog(abc, "Test file read").ShowAsync(); }