Back to Devexpress

How to: Specify a Command and KeyGesture for a Bar Item

wpf-6644-controls-and-libraries-ribbon-bars-and-menu-bars-examples-how-to-specify-a-command-and-keygesture-for-a-bar-item.md

latest919 B
Original Source

How to: Specify a Command and KeyGesture for a Bar Item

  • Jun 30, 2023

This example shows how to specify a command and custom short cut for a bar item. A command and short cut are assigned to the item via the Command and KeyGesture properties, respectively. In the example, a bar is docked to the BarContainerControl which is created manually.

xaml
<dxb:BarManager.Items>                
    <dxb:BarButtonItem Name="btnCut" 
                       Command="ApplicationCommands.Cut" 
                       KeyGesture="CTRL+1" 
                       CommandTarget="{Binding ElementName=textBox}" 
                       Content="{Binding Command.Text, RelativeSource={RelativeSource Self}}"/>
</dxb:BarManager.Items>