Can anyone enlighten me to a way I can Highlight the content of an input field OnFocus preferably by XAML only?
So if a user bring focus to a field, it will highlight the string or whatever is in there so they can for example just tab to it, and replace the existing string as soon as they start typing instead of having to manually highlight and delete it first?
I've seen answers that require code, but wondering if there's a XAML only route? Thanks!
I highly doubt there would be XAML code that is equivalent to the TextBox.SelectAll() method.
It should be as easy as attaching each TextBox's GotKeyboardFocus event to a single event handler like this.
private void TextBox_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
if (sender is TextBox)
((TextBox)sender).SelectAll();
}
<TextBox GotKeyboardFocus="TextBox_GotKeyboardFocus" />