How to bind ApplicationCommands to a ViewModel?

前端 未结 2 667
天命终不由人
天命终不由人 2020-12-09 05:21

I have successfully used a few custom commands using MVVM-Light, but I want my application to respond to the standard ApplicationCommands, not just at a Window level, but at

2条回答
  •  猫巷女王i
    2020-12-09 05:55

    I believe that you are looking for CommandBindings. I use something similar for some textboxes:

        
            
                
                    
                    
                
            
        
    

    Note that PreviewCanExecute and PreviewExecuted are also available.

    Edit: Check out the sample here to make it MVVM compliant.

提交回复
热议问题