Perform Common Tasks With XAF Actions
- 3 minutes to read
This article describes the most common tasks with XAF Actions.
- Use Action Settings
- Add an Action to a Controller
- Add an Action by applying the Action attribute to a business class method
- Customize an Action in the Application Model
- Customize an Action in code
- Create custom Action types and custom controls
- Troubleshoot Actions
Use Action Settings
The base class for all Action types is the ActionBase class. This class provides events, properties and methods that support the common Action behavior.
Events
- ActionBase.Executing and ActionBase.Executed occur when an end-user performs a specified manipulation: clicks a button, selects an item in a combo box, etc.
Properties
- ActionBase.Controller provides access to the parent Controller.
- ActionBase.Active determines the Action’s active/inactive state and visibility.
- ActionBase.Enabled determines an Action’s enabled/displayed state. A Disabled Action is visible in the UI, but is grayed out.
- ActionBase.TargetViewType, ActionBase.TargetViewNesting, ActionBase.TargetViewId, ActionBase.TargetObjectType, ActionBase.TargetObjectsCriteria, ActionBase.TargetObjectsCriteriaMode and ActionBase.SelectionDependencyType specify conditions for Action activation.
- ActionBase.Category specifies an Action’s category. The category determines the Action’s placement in an Action Container.
- ActionBase.ConfirmationMessage specifies the confirmation message displayed when an end-user executes an Action.
- ActionBase.Caption specifies the Action’s caption.
Tip
Access the ActionBase class’s members page for a complete list of available API.
Add an Action to a Controller
If you require an Action that applies to multiple business objects and takes user input, add this Action to a Controller.
- Add a Simple Action
- Add a Parametrized Action
- Add an Action that Displays a Pop-up Window
- Add an Action with Option Selection
You can also add an Action to a Controller in code.
public class ViewController1 : ViewController {
public ViewController1() {
SimpleAction action1 = new SimpleAction(this, "Action1", DevExpress.Persistent.Base.PredefinedCategory.View);
}
}
After you add an Action to a Controller, you can use the Designer to customize the Action.
Add an Action by Applying the Action Attribute to a Business Class Method
If you require an Action that applies to one business object and uses the business object’s parameters, apply the Action attribute to the business class’s method as shown below:
- Getting Started: Add a Simple Action Using an Attribute
- How to: Create an Action Using the Action Attribute
Use the Action attribute only for simple scenarios similar to those described in the articles. For greater flexibility, you can add an Action to a Controller.
Customize an Action in the Application Model
Information on Actions is available in the Application Model’s ActionDesign node.
- Place an Action in a Different Location
- Specify Action Settings
- How to: Include an Action to a Detail View Layout
Customize an Action in Code
You can access Actions and customize them in code.
- Customize Controllers and Actions
- How to: Customize ASP.NET Layout Elements Using Custom CSS Classes
- How to: Customize Action Controls
- How to: Deactivate (Hide) an Action in Code
- How to: Reorder an Action Container's Actions Collection
Create Custom Action Types and Custom Controls
In XAF, you can create custom Action types and custom controls. See the examples below:
- Create a custom Action type with a custom control (BarCheckItem) associated with it
- Create a custom Action with a custom control in an XAF ASP.NET applicaiton
Troubleshoot Actions
Use the articles below to learn how to diagnose and fix the most frequently encountered problems.