CommandItem Class

A command that the CompositeCommandBehavior aggregates to create a composite command.

Namespace: DevExpress.Mvvm.UI

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

Declaration

public class CommandItem :
    DependencyObjectExt

Remarks

Each CommandItem should contain the Command property that is the ICommand that the behavior should aggregate.

In the following code sample, the CompositeCommandBehavior takes two CommandItems, aggregates them to the CompositeCommand, and executes it when a user clicks the ThemedWindow‘s back button:

<dx:ThemedWindow ...
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:ViewModels="clr-namespace:CompositeCommandCommandPropertyName.ViewModels"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
    ShowBackButton="True">
    <dx:ThemedWindow.DataContext>
        <ViewModels:MainViewModel/>
    </dx:ThemedWindow.DataContext>
    <dxmvvm:Interaction.Behaviors>
        <dxmvvm:CompositeCommandBehavior CommandPropertyName="NavigateBackCommand">
            <dxmvvm:CommandItem Command="{Binding SaveCommand}"/>
            <dxmvvm:CommandItem Command="{Binding CloseCommand}"/>
        </dxmvvm:CompositeCommandBehavior>
    </dxmvvm:Interaction.Behaviors>
    <!-- ... -->
</dx:ThemedWindow>
using DevExpress.Mvvm;
using DevExpress.Mvvm.DataAnnotations;
using System.Windows;

public partial class MainViewModel : ViewModelBase {

    [Command]
    public void Save()
    {
      // ...
    }

    [Command]
    public void Close()
    {
      // ...
    }
}

Inheritance

Object
DispatcherObject
DependencyObject
Freezable
DevExpress.Mvvm.UI.Native.DependencyObjectExt
CommandItem
See Also