Home Forums WPF controls Xceed DataGrid for WPF Problem with autoselecting text on getting focus

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23881 |

    For our application, the desired behavior is when a text box is getting a focus, all text within that text box is automatically selected, so user can just start typing, saving keystrokes. I couldn’t find a property that controls this behavior, so I just attached an event to the text box:

    edPrice.GotFocus += delegate(object sender, RoutedEventArgs e)
    {
    edPrice.SelectAll();
    };
    Unfortunately, this works only if the focus is received through keyboard navigation, if a text box is selected with a mouse, the selection disappears as soon as mouse button is released. Handling the PreviewMouseLeftButtonUp (setting event argument’s Handled to true) helped, but completely broke mouse navigation. Re-selecting the text in MouseLeftButtonUp also got me nowhere.

    Any suggestions?

    Imported from legacy forums. Posted by Sergey (had 677 views)

    Xceed Support
    Member
    Post count: 5658

    There is a class you could like in the Xceed.Wpf.Controls namespace called AutoSelectTextBox. 😉

    The AutoSelectTextBox is the class we used in our default editors for the same reason as the onw you indicate…

    In addition to automatic text selection, this class also provides basic automatic focus navigation…

    Imported from legacy forums. Posted by Marcus [Xceed] (had 191 views)

    User (Old forums)
    Member
    Post count: 23064

    Since I don’t have the source code 🙂 Please, Marcus, tell me what you did to the TextBox to achieve this? Just my curiosity.

    Imported from legacy forums. Posted by Sergey (had 3424 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.