1

Is there a way to pass entered key as command parameter in InputBindings of Window? I tried achive this by code below, but it isn't working.

     <KeyBinding x:Name="KeyBinding" Command="{Binding ChoosePackageSizeFromKeyboard}" CommandParameter="{Binding ElementName=KeyBinding, Path=Key}" />

I don't wanna create binding for every key I wanna use, cause depending of condition it will be beetween 1 and 5 keys. Any ideas how to pass it to command?

Elterian
  • 11
  • 4

1 Answers1

0

I don't think it's possible to use KeyBinding the way you want to. You have to provide a value for the Key property for it to work.

What you could do instead is handle the KeyUp (or similar) event on the Window. If you want to bind on a Command, you can take a look at this SO answer for more details on how to pass the EventArgs to the command.

Julien Poulin
  • 12,737
  • 10
  • 51
  • 76