Introduction to Commands

The Command pattern was not introduced with WPF or Silverlight. Instead, the command-handling technique is a behavioral pattern first presented in the “Gang of Four” book Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (Addison-Wesley, 1994). It describes how the logic of a request should be encapsulated in a separate object.

The goal is to separate the semantics and object that invoke a command from the logic that executes the command, so that the same command can be used over different UI elements without having to rewrite the execution logic. For example, the classic commands you may find in a word processing application are Copy, Cut, and ...

Get Applied WPF 4 in Context now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.