ActionBase Class
The base class for Actions.
Namespace: DevExpress.ExpressApp.Actions
Assembly: DevExpress.ExpressApp.v24.2.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Remarks
Actions are abstract UI elements that allow you to perform specific operations in response to an end-user’s manipulations (see the SimpleAction.Execute event definition). Actions are contained within Controllers in their Controller.Actions lists. An Action’s presence in a particular Window (Frame) depends on whether the corresponding Controller is active in it. Note that you can also specify the availability context for individual Actions via their properties.
The ActionBase
class is the base class for all Action types. This class provides events, properties and methods that support the common Action behavior. They are:
- The ActionBase.Executing and ActionBase.Executed events are used to execute custom code before and after executing an Action.
- The ActionBase.Controller property provides access to the parent Controller.
- The ActionBase.Active and ActionBase.Changed members provide the Action activation mechanism.
- The ActionBase.TargetObjectType, ActionBase.TargetViewId, ActionBase.TargetViewNesting ActionBase.TargetViewType, ActionBase.TargetObjectsCriteria, ActionBase.TargetObjectsCriteriaMode and ActionBase.SelectionDependencyType properties specify conditions for Action activation (these conditions are checked only for Actions from View Controllers).
- The ActionBase.Enabled and ActionBase.Changed members represent mechanisms for making an Action enabled/disabled.
The XAF supplies several Action types derived from the Action class: SimpleAction, ParametrizedAction, PopupWindowShowAction, SingleChoiceAction and ActionUrl. Each of these types has a different purpose. For details, see the descriptions of these classes and the Actions topic.
To add an Action to a Controller, use the Controller’s Designer. Information specified for an Action in the Controller’s Designer or the Controller’s constructor in code is loaded to the Application Model. You can view all the Actions that will be created in your application. To do this, invoke the Model Editor and navigate to the ActionDesign | Actions node. Information on Actions is represented by properties of the Action child nodes. These properties can be initially set to default values or the values that you specified in the Controller’s constructor or in the Controller’s Designer. You can modify these values if the properties are not read-only.
Actions of the SimpleAction and PopupWindowShowAction types can be also added via the ActionAttribute attribute. Refer to the How to: Create an Action Using the Action Attribute topic to see an example.
In this documentation, built-in Actions are referred to by their identifiers specified by ActionBase.Id property. To find out what caption is assigned to a particular Action, use the Model Editor.
Execute Actions Programmatically
We do not recommend that you use the DoExecute
and other methods to execute Actions because such methods can contain UI-specific code. You can refactor your Action’s event handlers and extract the required code into separate methods. Call these separate methods directly without triggering UI-related Action code.
Programmatic execution of custom and built-in Actions is acceptable in rare advanced scenarios, for example, if you:
- Create a custom Action Container and call the
DoExecute
method inside the Action control. In this context, you have complete control over your custom code and can execute any action. Remember to trigger life-cycle events for your actions (such asExecute
). - Add new ways to invoke Actions from the UI (for example, support keyboard or voice control).
- Reuse a built-in Action in a specific context where you would need to write a lot of code to re-implement the Action’s internal business logic.
For more information on how to implement such complex requirements, refer to the following materials:
- XAF - How to execute Actions programmatically.
- “Related GitHub Examples” section of the SimpleAction.DoExecute topic.
- “Related GitHub Examples” section of the ParametrizedAction.DoExecute(Object) topic.