H
H
h1_0ne2019-06-12 14:17:04
WPF
h1_0ne, 2019-06-12 14:17:04

How to track pressed key in mvvm?

I have a Textbox which is used as a search engine. I need to apply the search by pressing the Enter key, not reacting to pressing other keys. If I didn’t do it through mvvm, I could use the KeyEventArgs parameter (it seems to be). And how do I track the key pressed using the mvvm approach?5d00df26336a2073820329.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Foggy Finder, 2019-06-12
@FoggyFinder

Use KeyBinding :

<TextBox.InputBindings>
    <KeyBinding Key="Enter" Command="{Binding SearchCommand}" />
</TextBox.InputBindings>

P
Peter, 2019-06-12
@petermzg

https://docs.microsoft.com/en-us/dotnet/framework/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question