That’s the file in a WPF project that serves as the entry point for your application. Instead, here’s a simple way to register a global event handler that works on any TextBox in your application:įirst, open up your file. So how do you go about getting this behaviour back? Your first instinct might be to simply catch the GotFocus event on each TextBox and call the SelectAll() method, but that’ll get pretty old by about the thirtieth time you’ve done it. This is really weird for someone who’s used to the “select all on focus” behaviour, and time-consuming for a beginner (who inevitably uses their right-arrow key to scroll to the end of the text, and backspaces to erase it all). When you tab into a TextBox your cursor sits at the beginning of the text, and when you start typing, your new text is simply inserted at the beginning. This means that you can tab into a TextBox and then start typing, and whatever was already in there will be automatically overwritten. The title of this post is almost pure Google-juice, because this is a trick that I had to relearn on the weekend after a series of unsuccessful searches on the topic.Ī behaviour in Windows that most of us are fairly accustomed to (whether we realise it or not) is that upon entering a TextBox, the text is automatically selected.
0 Comments
Leave a Reply. |