Back to Devexpress

ConfirmationBehavior.CommandPropertyName Property

wpf-devexpress-dot-mvvm-dot-ui-dot-confirmationbehavior-dfbaf1e9.md

latest3.1 KB
Original Source

ConfirmationBehavior.CommandPropertyName Property

Gets or sets a name of an associated control’s command 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 property that should invoke the confirmation message box.

|

Remarks

Note that many controls have a Command property. If the command should trigger ConfirmationBehavior, then you do not need to specify CommandPropertyName.

When a user triggers a command you specified in CommandPropertyName , the control first displays a confirmation message. If a user confirms the operation, the ConfirmationBehavior executes the command specified by the Command property.

The following code sample specifies the CommandPropertyName property and enables a confirmation message when a user clicks the ThemedWindow‘s back button. If a user confirms the operation, the ConfirmationBehavior executes the Close command:

xaml
<dx:ThemedWindow ...
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm">
    <dx:ThemedWindow.DataContext>
        <ViewModels:MainViewModel/>
    </dx:ThemedWindow.DataContext>
    <dxmvvm:Interaction.Behaviors>
        <dxmvvm:ConfirmationBehavior Command="{Binding CloseCommand}"
                MessageText="Do you want to navigate back?" CommandPropertyName="NavigateBackCommand">
        </dxmvvm:ConfirmationBehavior>
    </dxmvvm:Interaction.Behaviors>
    <!-- ... -->
</dx:ThemedWindow>
csharp
using DevExpress.Mvvm;
using DevExpress.Mvvm.DataAnnotations;

public class MainViewModel : ViewModelBase {
    [Command]
    public void Close() {
        // ...
    }
}
vb
Imports DevExpress.Mvvm
Imports DevExpress.Mvvm.DataAnnotations

Public Class MainViewModel
    Inherits ViewModelBase

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

See Also

ConfirmationBehavior Class

ConfirmationBehavior Members

DevExpress.Mvvm.UI Namespace