WPF Command for SurfaceTextBox which fires up when user hit enter key on SurfaceKeyboard

Recently I came arround the need of invoke a commad exposed by the view model when the user is typing on a SurfeceTextBox and the enter key is hitted.

Well the soluzion is simple and clean the way is to use a KeyBinding on the SurfaceTextBox and here is the code:

        <s:SurfaceTextBox >
                <KeyBinding Command="{Binding SearchCommand, Mode=OneWay}"  Key="Enter" />


Ultimi Post


Articles and content of this blog aren't and shouldn't be interpreted as professional advice or opinions. Author writes on a personal basis and as part of their own research, experimentation and knowledge. Opinions expressed aren't in any way attributable to professional affiliations / institutional thereof or to opinions that the author express as part of their roles / positions that may be quite different from that reported here.