Skip to content

CommandService Component

gstaas edited this page Nov 6, 2014 · 2 revisions

A command is an action that is invoked from a menu item or tool strip button. You can create menus, menu items, and tool strip buttons and associate them with commands. The command specifies its appearance and behavior in the UI: text, icon, keyboard shortcut, and actual command action.

CommandService creates standard menus, displays the currently available application commands to the user in menus and tool strips, displays context menus, and processes keyboard shortcuts.

This component, or one like it, is useful to any application that activates commands through menus and tool strips and is used by nearly all the ATF samples. Because it is a component, applications simply need to add CommandService to the MEF TypeCatalog. The ATF standard command components, such as StandardEditCommands or StandardFileCommands, require CommandService to work. In fact, if you left out CommandService, your application would have no menus at all, unless you added them some other way.

For WinForms, applications also need to use the StatusService and SettingsService components, because CommandService imports IStatusService and ISettingsService.

For more information on satisfying components' import needs, see Using ATF Components.

CommandService implements the ICommandService interface. ICommandService offers methods similar to IControlHostService. ICommandService offers methods to register and unregister menus and commands, instead of controls. The related interface ICommandClient contains methods to determine whether a command can be performed, update the command's menu, and actually perform the command.

There are versions of CommandService and ICommandService for both WinForms and WPF.

For more information about CommandService and commands, see Commands in ATF. For information on using CommandService, see CommandService.

Topics in this section

Clone this wiki locally