0

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 defined 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?

Community
  • 1
  • 1
Mike
  • 1
  • 1

1 Answers1

0

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>
Bathineni
  • 3,436
  • 18
  • 25