Instead of attaching a PreviewKeyUp
event with each TextBox
in my app and checking if the pressed key was an Enter key and then do an action, I decided
Since this question was asked, there is now an InputBindings
property on TextBoxes and other controls. With this, a purely XAML solution can be used, rather than using custom controls. Assigning KeyBinding
s for Return
and Enter
to point to a command can do this.
Example:
Some have mentioned that Enter
does not always work, and Return
may be used on some systems.