Hotkey commands for Silverlight in MVVM?

前端 未结 3 919
猫巷女王i
猫巷女王i 2021-02-04 15:30

I\'m trying to fire commands based on keystrokes in Silverlight. As I understand you cannot use AccessKey or AcceleratorKey in Silverlight. Also it looks like the might be helpf

3条回答
  •  猫巷女王i
    2021-02-04 16:19

    The MVVM toolkit contains an interesting CommandReference class that allows you to bind InputBindings to ViewModel commands. I'm not sure it works for Silverlight, but you can give it a try...

    OK, as RandomEngy pointed out, there are no InputBindings in Silverlight...

    However, I think you could use attached behaviors. It's a way to "bind" an event to a command of the ViewModel. Marlon Grech has a good implementation here

提交回复
热议问题