Situation :
I've started coding a model and its commands inside a WPF project, now I've decided to move this 'model' to a class library so it does not depend on any of the WPF types.
The ultimate goal is to be able to use it on another framework than WPF, Forms for instance.
For the model it was painless, there were no dependencies at all on any WPF type, however the model commands class returns a bunch of errors : Cannot resolve symbol 'RoutedUICommand'
Here's an extract of the class :
public static class MyModelCommands
{
private static readonly RoutedUICommand _addFiles;
static MyModelCommands()
{
_addFiles = new RoutedUICommand("Add files", "AddFiles", typeof (MyModelCommands));
}
public static RoutedUICommand AddFiles
{
get { return _addFiles; }
}
// ...
}
Looking at the RoutedUICommand documentation :
The Execute and CanExecute methods on a RoutedCommand do not contain the command logic for the command, as is the case with a typical ICommand. The Execute and CanExecute methods on a RoutedCommand do not contain the command logic for the command, as is the case with a typical ICommand.
I've come to the conclusion that I should use my own derivation of ICommand, I'd even benefit from that in the sense that I'll implement the commands logic inside the class library, which is great.
But what about the WPF project, should I create a facade of this class that encompasses these commands in RoutedUICommand(s) and update my CommandBindings to the handlers in the class library ?