i want to execute a command if the KeyDown-event occurs. This command should only be fired if the Enter-Key was pressed.
How can I realize that in a MVVM-architecture?
I am using WPF and VB.NET.
Thank you!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The easiest way is to implement some kind of AttachedBehavior which allows you to hook a ViewModel command to a KeyDown event.
Usually I use the code posted here for attaching VM Command’s to XAML Events, however I have not tested it with a KeyDown event.
If that doesn’t work, I believe other 3rd party toolkits such as Prism or MVVM Light have their own implementation of the behavior