I have a popup with a TextBox in which the user must enter the ticket number, and then when the user presses the enter key, I want the ticket number to be passed to the ViewModel, which will retrieve the ticket.
Here is the xaml for the TextBox :
<TextBox x:Name="TicketNumber"> <i:Interaction.Triggers> <i:EventTrigger EventName="KeyDown"> <i:InvokeCommandAction Command="{Binding OpenTicketCommand}" CommandParameter="{Binding ElementName=TicketNumber, Path=Text}"/> </i:EventTrigger> </i:Interaction.Triggers> </TextBox>
The above works with any keystroke, but I really want this to happen when the enter key is pressed. How can I do it?
EDIT: I suppose it would have to be done programmatically (hence the name), but if that is not so good.
wpf mvvm
Brandon moore
source share