WPF: Why does CommandBindings only use RoutedCommand which breaks MVVM?

I apologize for this somewhat general question, but I don't understand the logic behind CommandBindings in WPF.

They only allow for RoutedCommands, which I generally don't want to use because I need my logic to be in the ViewModel (I want to adhere to MVVM as much as I can). Why not allow for ICommands? Why only RoutedCommands?

I want to reap the benefits of a single object with command logic + key bindings, so that I can use a command from a context menu, a key shortcut and possibly a button too, and have everything done automatically for me. Since I don't want to use RoutedCommands, It seems that I'll have to inherit from MenuItem and ICommand and implement my own version of a Window's CommandBindings. That's not too difficult, but is that the right thing to do? Am I missing something?

链接地址: http://www.djcxy.com/p/56206.html

上一篇: 确保在MVVM WPF应用程序中的UI线程上调用OnPropertyChanged()

下一篇: WPF:为什么CommandBindings只使用破坏MVVM的RoutedCommand?