代码改变世界

Built-in command libraries in WPF

2011-12-29 20:16  一一九九  阅读(217)  评论(0编辑  收藏  举报

Aside from supporting the overall concept of commands, WPF has five built-in libraries of commands.

  • ApplicationCommands  this library contains commonly used commands such as Cut, Copy, paste, new, Open, Save, Undo, Close and many others.
  • ComponentCommands   these are commands for moving around inside an application. these can easily be confused with some of the editing commands as well as navigation commands. The commands in this library are for more general use than the other two. here you will find commands such as moveDown.ExtendSelectionLeft.ScrollbyLine, SelectToEnd, and many others.
  • EdtiingCommands this library is helpfu for dealing with text. it includes commands for alignment, formatiing, and the navigation of text. some exampls of command names are toggleBold, alignLeft, and DecreaseFontSize.
  • MediaCommands these are commands for controlling audio and video in your applications. some typical commands are play, pause, and increaseVolume.
  • NavigationCommands these commands are most useful for navigating in an application built around a web browser metahpor. commands include browseForward, nextpage, previouspage, refresh, and search.

Command bindings raise an event called CanExecute. We can handle this event and inform the binding if the command is available.

UIElement defines a collection of input bindings that are automatically avaiable to all of the element’s children. Usually, you’ll create your input bindings at the windows level of your applications.

There are two types of input binding: keyBinding and MouseBinding. As you might have guessed, KeyBinding is for activating commands with the keyboard, and mouseBinding is for activating them with the mouse.

From Sams.Teach.Yourself.WPF.in.24.Hours.Jun.2008.pdf