/// <summary>
        /// Prompts the user for input and returns the text the user entered.
        /// </summary>
        /// <param name="displayText">The text to be displayed in the input box.</param>
        public string ShowInputBox(string displayText)
        {
            var viewModel = new InputBoxViewModel(displayText);

            if (ShowDialog(viewModel) == true)
            {
                return(viewModel.InputText);
            }
            return(null);
        }
        /// <summary>
        /// Shows an input box and gets the string entered by the user.
        /// </summary>
        /// <param name="owner">The window, if any,  that owns the InputBox window.</param>
        /// <param name="title">The title to display for the input box.</param>
        /// <param name="originalText">The initial text to display in the entry portion of the input box.</param>
        /// <returns>The entered text, as a string; an empty string if the user cancels.</returns>
        public string ShowInputBox(object owner, string title, string originalText)
        {
            string newText = String.Empty;

            InputBoxViewModel viewModel = new InputBoxViewModel(title, originalText);
            InputBox          view      = new InputBox(viewModel);

            bool completed = view.ShowDialog() ?? false;

            if (completed)
            {
                newText = viewModel.Text.Trim();
            }

            return(newText);
        }
Example #3
0
        public static string Show(string title, string message, string pretext)
        {
            ReflectionUtility.EnsureMainThread();
            var         viewModel     = new InputBoxViewModel(title, message, pretext);
            InputWindow messageWindow = new InputWindow
            {
                DataContext = viewModel,
                Owner       = Application.Current.MainWindow
            };

            if (messageWindow.ShowDialog().Value)
            {
                return(viewModel.Text);
            }
            return(null);
        }
Example #4
0
 public InputBox(InputBoxViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }