Created
April 20, 2010 11:56
-
-
Save glebd/372343 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in startup code | |
EventManager.RegisterClassHandler( | |
typeof (TextBox), | |
TextBox.GotFocusEvent, | |
new RoutedEventHandler(TextBox_GotFocus)); | |
EventManager.RegisterClassHandler( | |
typeof(TextBox), | |
TextBox.GotKeyboardFocusEvent, | |
new RoutedEventHandler(TextBox_GotFocus)); | |
private static void TextBox_GotFocus(object sender, RoutedEventArgs e) | |
{ | |
var textBox = sender as TextBox; | |
if (textBox == null) return; | |
textBox.SelectAll(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on http://madprops.org/blog/wpf-textbox-selectall-on-focus/