Commands
The DataForm enables you to control its behavior by customizing its available commands in an MVVM-friendly way.
DataFormCommandProvider
The DataForm provides the public DataFormCommandProvider
class, which exposes the "execute" and "can-execute" logic for all its commands. The component processes these commands according to its current provider.
Execute Logic Methods
The "execute" logic methods identify the logic that is executed when a certain command is invoked.
Execute Logic Methods
Can-Execute Logic Methods
The "can-execute" logic methods enable you to identify whether a certain command can be executed or not.
CanExecute Logic Methods
Customizing the DataFormCommandProvider
To design and set a custom DataFormCommandProvider
, follow the steps:
-
Create your own class that inherits from
DataFormCommandProvider
:Define a Custom CommandProvider
-
Override the methods of the commands that will be customized.
The following example aims at changing the
MoveCurrentToNext
andMoveCurrentToPrevious
execution logic to start editing the item immediately after it is set as a current one and bypass the logic in the same place.Customizing MoveCurrentToNext and MoveCurrentToPrevious
A common requirement for the DataForm is to add confirmation message boxes when CRUD operations are executed. The example below implements the scenario for theCommitEdit
andCancelEdit
commands.Customizing CommitEdit and CancelEdit
-
The last thing to do is set the
CommandProvider
property of the DataForm to the newly-createdCustomKeyboardCommandProvider
class:Set the CommandProvider Property in XAML
Set the CommandProvider Property in Code
Executing Commands Manually
By using the RadDataFormCommands
class, you can set a sequence of commands that will be performed one after another. For example, you can handle the click
event of a button, move to the next item, and place the DataForm it in edit mode. However, when invoking the commands in such a manner, you have to add a second parameter that points out the target UI element, as shown in the following example.