Example #1
0
        /// <summary>
        /// The OnTextbox_MouseDoubleClick.
        /// </summary>
        /// <param name="sender">The sender<see cref="object"/>.</param>
        /// <param name="e">The e<see cref="MouseButtonEventArgs"/>.</param>
        private static void OnTextbox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (!(sender is TextBox textbox))
            {
                return;
            }

            UIThreadHelper.DelayedInvokeAsync(() =>
            {
                textbox.Focus();
                textbox.SelectAll();
            }, 200);
        }
Example #2
0
        /// <summary>
        /// The OnTextbox_PreviewMouseLeftButtonDown.
        /// </summary>
        /// <param name="sender">The sender<see cref="object"/>.</param>
        /// <param name="e">The e<see cref="MouseButtonEventArgs"/>.</param>
        private static void OnTextbox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (!(sender is TextBox textbox))
            {
                return;
            }

            if (!textbox.IsFocused)
            {
                UIThreadHelper.DelayedInvokeAsync(() =>
                {
                    textbox.Focus();
                    textbox.SelectAll();
                }, 200);
            }
        }