Executing Commands

So far, you've taken a close look at commands, considering both the base classes and interfaces and the command library that WPF provides for you to use. However, you haven't yet seen any examples of how to use these commands.

As explained earlier, the RoutedUICommand doesn't have any hardwired functionality. It simply represents a command. To trigger this command, you need a command source (or you can use code). To respond to this command, you need a command binding that forwards execution to an ordinary event handler. You'll see both ingredients in the following sections.

Command Sources

The commands in the command library are always available. The easiest way to trigger them is to hook them up to a control that implements ...

Get Pro WPF in C# 2008: Windows Presentation Foundation with .NET 3.5, Second Edition 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.