CHAPTER 9

Image

Commands

In Chapter 5, you learned about routed events, which you can use to respond to a wide range of mouse and keyboard actions. However, events are a fairly low-level ingredient. In a realistic application, functionality is divided into higher-level tasks. These tasks may be triggered by a variety of actions and through a variety of user-interface elements, including main menus, context menus, keyboard shortcuts, and toolbars.

WPF allows you to define these tasks—known as commands—and connect controls to them so you don’t need to write repetitive event-handling code. Even more important, the command feature manages the state of ...

Get Pro WPF 4.5 in C#: Windows Presentation Foundation in .NET 4.5, Fourth 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.