Back to Devexpress

CompositeCommandBehavior.CommandPropertyName Property

wpf-devexpress-dot-mvvm-dot-ui-dot-compositecommandbehavior-d517791a.md

latest3.3 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public string CommandPropertyName { get; set; }
vb
Public Property CommandPropertyName As String

Property Value

TypeDefaultDescription
StringCommand

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:

xaml
<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>
csharp
using DevExpress.Mvvm;
using DevExpress.Mvvm.DataAnnotations;
using System.Windows;

public partial class MainViewModel : ViewModelBase {

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

    [Command]
    public void Close()
    {
      // ...
    }
}
vb
Imports DevExpress.Mvvm
Imports DevExpress.Mvvm.DataAnnotations
Imports System.Windows

Public Partial Class MainViewModel
    Inherits ViewModelBase

    <Command>
    Public Sub Save()
        ' ...
    End Sub

    <Command>
    Public Sub Close()
        ' ...
    End Sub
End Class

See Also

CompositeCommandBehavior Class

CompositeCommandBehavior Members

DevExpress.Mvvm.UI Namespace