Dec 23, 2013 at 3:59 PM
Edited Dec 23, 2013 at 4:32 PM
I want to use ICommandManager in my project but it does not fully satisfy my needs.
So, i've already rewrite it a bit in me forked repo and will do pull request soon.
In rewrited ICommandManager i support custom ICompositeCommand. Also i've added UICompositeCommand and CanExecute implementation.
So i can now add it as menu item and it will be
if there is no registred commands or all of them return false from CanExecute.
Also i want to ask about the actuality of this.
Also i've remembered about ApplicationCommands, ComponentCommands, NavigationCommands, MediaCommands.
And it's implementation.
I would like use this commands and some other custom in context menus and toolbars, but because of plugin architecture (i have a MenuService where you can add items to menu or toolbar by tag dynamicaly) i can`t use it.
So i want to think about it a bit here.
I see one way to solve it now:
- Create custom routed command
- In IViewModelCommandManager
- * add methods like Register/Unregister RoutedCommand(IRoutedCommand, ICommand) which would add this mapping to Dictionary<IRoutedCommand, ICommand>
- * add methods like OnRoutedExecute(IRoutedCommand) where the ICommand, mapped to this IRoutedCommand, would be executed.
- In Execute method, call ViewModel.ViewModelCommandManager.OnRoutedExecute(this). For this, i think, i can use CommandManager.AddExecuteHandler to register a View/ViewModel/IViewModelCommandManager as a handler.
So, what do you think.
Dec 23, 2013 at 7:38 PM
Sounds like good ideas. I think one of the improvements can be to allow any ICompositeCommand to be registered (in the CreateCommand method). It will default to CompositeCommand, but will allow overrides.
Another overload could cover the RoutedUICommands. We would need to translate routed commands into CompositeCommands though due to the different nature of RoutedUICommand).
I would love to see your pull request.