Skip to main content

CompositeCommandBehavior.CommandPropertyName Property

Gets or sets the name of the associated control‘s ICommand property. This is a dependency property.

Namespace: DevExpress.Mvvm.UI

Assembly: DevExpress.Xpf.Core.v24.1.dll

NuGet Package: DevExpress.Wpf.Core

Declaration

public string CommandPropertyName { get; set; }

Property Value

Type Default Description
String Command

The name of the ICommand property.

Remarks

If the associated control does not have a Command property, assign the CommandPropertyName property to the name of an ICommand property. The behavior binds its CompositeCommand to the specified property.

The following code sample executes a CompositeCommand 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()
    {
      // ...
    }
}
See Also