I am struggling with MVVM in my application. I have there a TabControl whose every Tab hosts a control that allows somehow editing a file. For instance, text files or images. Each control is bound to a class from ViewModel area (as is depict at the diagram). I also have RoutedUICommands. One of these commands is WordWrap and only makes sense in case of text files. This command is used in MenuItem or a Button etc. I'd like to enable it only if a text control is the target for this command. How to do it properly according to MVVM?
More details:
XAML for the Window has:
<Window.CommandBindings>
<CommandBinding Command="local:EditorCommands.WordWrap"
Executed="WordWrapExecuted"
CanExecute="CommandCanBeExecutedWhenAnythingIsOpen"/>
</Window.CommandBindings>
A menu item is used this way:
<MenuItem Command="local:EditorCommands.WordWrap"/>
The first thing is the Executed and CanExecute event handlers: they are in Window class although my understanding if MVVM is, that the logic should be in ViewModel only.
What's more, the sender in these function is an instance of a window. Why is it not a target of the command?
Should I write my own successors of RoutedUICommand for every command?