Prev | Current Page 528 | Next

Matthew MacDonald

"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"


The RoutedUICommand Class
Most of the commands you??™ll deal with won??™t be RoutedCommand objects but will be
instances of the RoutedUICommand class, which derives from RoutedCommand. (In fact,
all the ready-made commands that WPF provides are RoutedUICommand objects.)
RoutedUICommand is intended for commands with text that is displayed somewhere in
the user interface (for example, the text of a menu item or the tooltip for a toolbar button).
The RoutedUICommand class adds a single property??”Text??”which is the display text for that
command.
The advantage of defining the command text with the command (rather than directly on
the control) is that you can perform your localization in one place. However, if your command
text never appears anywhere in the user interface, the RoutedCommand class is equivalent.
nNote You don??™t need to use the RoutedUICommand text in your user interface. In fact, there may be good
reasons to use something else. For example, you might prefer ???Print Document??? to just ???Print,??? and in some
cases you might replace the text altogether with a tiny graphic.
The Command Library
The designers of WPF realized that every application is likely to have a large number of commands
and that many commands are common to many different applications. For example,
all document-based applications will have their own versions of the New, Open, and Save
CHAPTER 10 n COMMANDS 297
commands.


Pages:
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540