Keybinding a RelayCommand

后端 未结 6 810
有刺的猬
有刺的猬 2020-12-03 13:52

I\'m using the RelayCommand in my app. It\'s great for putting the code in the viewmodel, but how do I bind keystrokes to my command?

RoutedUICommand has its InputGe

6条回答
  •  我在风中等你
    2020-12-03 14:10

    Assuming your RoutedCommands are defined statically:

    #region DeleteSelection
    
        /// 
        /// The DeleteSelection command ....
        /// 
        public static RoutedUICommand DeleteSelection
            = new RoutedUICommand("Delete selection", "DeleteSelection", typeof(ChemCommands));
    
        #endregion
    

    Bind in XAML thus:

    
        
    
    

    Regards,

    Tim Haughton

提交回复
热议问题