// TextboxDialog for LINQPad // You can use it anywhere by adding the following code to MyExtensions class on Linqpad6. // Usage: // var lines = MyExtensions.ReadLines() // foreach (var line in lines) // Console.WriteLine(line); public static class MyExtensions { // Write custom extension methods here. They will be available to all queries. public static IEnumerable ReadLines(string title = null) { var win = new System.Windows.Window() { Width = 400, Height = 300, Title = title ?? string.Empty }; var grid = new System.Windows.Controls.Grid(); grid.RowDefinitions.Add(new System.Windows.Controls.RowDefinition() { Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star) }); grid.RowDefinitions.Add(new System.Windows.Controls.RowDefinition() { Height = new System.Windows.GridLength(36) }); var margin3 = new System.Windows.Thickness(3); var tbox = new System.Windows.Controls.TextBox() { Margin = margin3, AcceptsReturn = true, AcceptsTab = true, VerticalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Auto, }; var btnOk = new System.Windows.Controls.Button() { Content = "OK", Margin = margin3, Width = 80 }; var btnCancel = new System.Windows.Controls.Button() { Content = "Cancel", Margin = margin3, Width = 80 }; btnOk.Click += (_, _) => { win.DialogResult = true; win.Close(); }; btnCancel.Click += (_, _) => { win.DialogResult = false; win.Close(); }; var sp = new System.Windows.Controls.StackPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, }; sp.Children.Add(btnOk); sp.Children.Add(btnCancel); System.Windows.Controls.Grid.SetRow(tbox, 0); System.Windows.Controls.Grid.SetRow(sp, 1); grid.Children.Add(tbox); grid.Children.Add(sp); win.Content = grid; return win.ShowDialog() == true ? tbox.Text.Split("\r\n") : new string[0]; } }