I am using the implementation give at Bind TextBox on Enter-key press to handle the enter key for text box.
But I am using MVVm pattern for my application. Therefore I have defi开发者_StackOverflowned the ICommand
handler in my VieModel
class. I want to bind it to view.
The sample application uses
InputBindingsManager.UpdatePropertySourceWhenEnterPressed="TextBox.Text"
and I want to use
InputBindingsManager.UpdatePropertySourceWhenEnterPressed="{Binding myCommandHandler}"
instead.
Can anybody suggest what modification are required in the code?
You can go for inputbindings for a textbox. in this you can bind a Icommand object to command property ok keybindings
Here is the sample code
<TextBox Text="{Binding Firstname, UpdateSourceTrigger=PropertyChanged}">
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding ValidationCommand}">
</KeyBinding>
</TextBox.InputBindings>
</TextBox>
精彩评论