Skip to main content

DevExpress v24.1 Update — Your Feedback Matters

Our What's New in v24.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DXCommand

DXCommand allows you to bind a command property to the method or property. The DevExpress binding mechanism requires special language expressions. Refer to the following topic for more information: Language Specification. The code sample below shows how to specify the Execute and CanExecute delegates.

<Button Content="OK" Command="{DXCommand Execute='Save(); Close()', CanExecute='CanSave() and CanClose()'}"/>

If you bind DXCommand.CanExecute to a property, you need to raise the PropertyChanged event to update the CanExecute state.

You can pass a parameter to the method that you call.

<TextBlock x:Name="tb" Text="text"/>
<Button Content="OK" Command="{DXCommand Execute='Save(@e(tb).Text)', CanExecute='CanSave(@e(tb).Text)'}"/>

Use the @parameter reserved word to access the CommandParameter value.

<TextBlock x:Name="tb" Text="text"/>
<Button Content="OK" Command="{DXCommand Execute='Save(@parameter)', CanExecute='CanSave(@parameter)'}" CommandParameter="{DXBinding @e(tb).Text}"/>

The DXCommand extension supports the “=” operator.

<Button Command="{DXCommand '@e(checkBox).IsChecked=true'}"/>