Menu-driven software applications commonly include shortcut keys (or hotkeys) to allow users to navigate through the menus using keyboard itself. Hotkeys not only help in quickly accessing menu items using keyboard but also reduce the reliance on mouse. This can significantly speed up tasks for application users who prefer keyboard interaction over mouse interaction. Common hotkeys such as Ctrl + N for New, Ctrl + O for Open, Ctrl + C for Copy, etc. are widely recognized and expected by users in a menu-based software application.
The Menu control supports hotkeys to make the interaction easier and faster with WPF applications. You can set the hotkeys for various menu items in the Menu control using HotKey property of the C1MenuItem class, as showcased in the following steps:
XAML |
Copy Code
|
---|---|
<c1:C1MenuItem Command="New" HotKey="Ctrl+N"></c1:C1MenuItem> <c1:C1MenuItem Command="Open" HotKey="Ctrl+O"></c1:C1MenuItem> |
XAML |
Copy Code
|
---|---|
<Window.CommandBindings> <CommandBinding Command="New" Executed="CommandBinding_Executed_New"></CommandBinding> <CommandBinding Command="Open" Executed="CommandBinding_Open_Executed"></CommandBinding> </Window.CommandBindings> |