Commands

Commands are supported in Catel. The base class for commands is Command.

Code snippets

vmcommand - declare a command on a view model

vmcommandwithcanexecute - declare a command with support for CanExecute on a view model

Explanation

To implement commands, and still be able to unit test the view models, a separate command is introduced. This command allows a developer to implement a command that can be invoked both via code (unit testing) and UI.

The TCanExecuteParameter is the parameter that is passed to the CanExecute of the command, ands saves the developer from casting the object (as in the interface ICommand to a typed object). The same goes for TExecuteParameter which makes the Execute of the command typed.