Skip to main content

NavBarItem.Command Property

Gets or sets the command to invoke when the NavBar item is clicked.

Namespace: DevExpress.Xpf.NavBar

Assembly: DevExpress.Xpf.NavBar.v21.2.dll


public ICommand Command { get; set; }

Property Value

Type Description

An ICommand object to invoke when the NavBar item is clicked.


If a NavBarItem was selected via a click at runtime, a Command is executed and the NavBarItem.Select and NavBarItem.Click events fire. If an end-user clicks an already selected item, the NavBarItem.Select event is skipped.

The Command can receive additional custom parameters (specified via the NavBarItem.CommandParameter) and a target object on which the command is executed (specified via the NavBarItem.CommandTarget).

The code below illustrates an example of defining a command:

    <CommandBinding Command="{x:Static custom:MainWindow.myCommand}"
namespace myApplicationNamespace {
    public partial class MainWindow : Window {
        public static RoutedCommand myCommand = new RoutedCommand();
        public MainWindow() {
        private void myCommandExecuted(object sender, ExecutedRoutedEventArgs e) {
            //Actions to perform
            . . .
        private void myCommandExecute(object sender, CanExecuteRoutedEventArgs e) {
            //Case of command's availability
            if (. . .) {
                e.CanExecute = true; }

To use the command as the user clicks a NavBarItem, assign it to the Command property of this group as in the following code:

<dxn:NavBarGroup Content="My Group" Name="navBarGroup1" Command="{x:Static custom:MainWindow.myCommand}" />
See Also