Assembly: PresentationCore (in PresentationCore.dll)
Initializes a new instance of theclass.
|KeyBinding(ICommand, Key, ModifierKeys)|
Gets a value that indicates whether the object can be made unmodifiable. (Inherited from Freezable.)
Gets or sets the command-specific data for a particular command.(Inherited from InputBinding.)
Gets or sets the target element of the command.(Inherited from InputBinding.)
Gets or sets the gesture associated with this InputBinding.Gesture.). (Overrides
Gets a value that indicates whether the object is currently modifiable. (Inherited from Freezable.)
Gets a value that indicates whether this instance is currently sealed (read-only).(Inherited from DependencyObject.)
A KeyGesture with a ICommand, such as a RoutedCommand. RoutedCommand is the primary implementation of the ICommand interface for the WPF commanding system . In general, when the KeyGesture is executed the command is invoked, although the command behavior is further influenced by command-specific factors such as the CanExecute value. For more information on commanding, see the Commanding Overview.associates a
With the exception of the function keys and the numeric keypad keys, a valid KeyGesture must contain exactly one Key and one or more ModifierKeys. Function keys and numeric keypad keys do not require a modifier key in order to be a valid KeyGesture. It is possible to specify an invalid KeyGesture and a with an invalid associated gesture, either through XAML or code. For instance, there is no validation that prevents creating and binding a KeyGesture that contains only a nonfunction key, or only modifiers but no key. Such a will never attempt to invoke its associated command.
When defining a KeyGesture. The first way to establish a in XAML is to define the Gesture attribute of the element, which enables a syntax to specify keys and modifiers as a single string, for example "CTRL+P". The second way is to define the Key attribute and the Modifiers attributes of the element. Both ways of setting the KeyGesture are equivalent and modify the same underlying object, but there will be a conflict if both are used. In the case when the Key, Modifiers, and the Gesture attributes are all set, the attribute which is defined last will be used for the KeyGesture. You can potentially have situations where for example a Key set last will overwrite just the Key component of a preceding Gesture but leave the Gesture's modifiers the same. In general, it is recommended that you use only the Gesture attribute from XAML; this will avoid ambiguity, provides the most streamlined syntax, and provides the most straightforward representation for serialization.in Extensible Application Markup Language (XAML) there are two ways to specify the
A RegisterClassInputBinding on the CommandManager class. The most typical way to define a is within the control template, setting the InputBindings property in XAML by declaring one or more MouseBinding or elements.can be defined on a specific object or at the class level by registering a
The following example creates a InputBindingCollection of the root window.and adds it to the
<Window.InputBindings> <KeyBinding Command="ApplicationCommands.Open" Gesture="CTRL+R" /> </Window.InputBindings>
Available since 3.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.