Back to Devexpress

ConfirmationBehavior.Command Property

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

latest2.5 KB
Original Source

ConfirmationBehavior.Command Property

Gets or sets the command that runs if the user accepts the confirmation message. This is a dependency property.

Namespace : DevExpress.Mvvm.UI

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

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public ICommand Command { get; set; }
vb
Public Property Command As ICommand

Property Value

TypeDefaultDescription
ICommandnull

The associated control’s Command property.

|

Remarks

The following code sample attaches a command to a Button and enables a confirmation message for this command:

xaml
<Button Content="Close">
    <dxmvvm:Interaction.Behaviors>
        <dxmvvm:ConfirmationBehavior EnableConfirmationMessage="{Binding IsSaved, Converter={StaticResource BooleanNegationConverter}}" 
                                     Command="{Binding CloseCommand}" MessageText="The document has unsaved changes. Do you want to close the document?"/>
    </dxmvvm:Interaction.Behaviors>
</Button>
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

If a control does not have a Command property, you can use the CommandPropertyName property to attach the behavior to the command.

See Also

ConfirmationBehavior Class

ConfirmationBehavior Members

DevExpress.Mvvm.UI Namespace