Back to Devexpress

Add a Parametrized Action

expressappframework-402155-getting-started-in-depth-tutorial-blazor-add-actions-menu-commands-add-a-parametrized-action.md

latest4.5 KB
Original Source

Add a Parametrized Action

  • Apr 10, 2025
  • 4 minutes to read

This lesson explains how to add a Parametrized Action. The Parametrized Action displays an editor that allows users to type in a parameter value before they run the action.

The instructions below demonstrate how to add an action that searches for a DemoTask object by its Subject property value and displays the Detail View of the found object.

Note

Before you proceed, take a moment to review the previous lessons:

Step-by-Step Instructions

  1. Add a new View Controller to the MySolution.Module project, as described in the Add a Simple Action lesson. Name it FindBySubjectController.

  2. In the MySolution.Module | Controllers | FindBySubjectController.cs file, specify the controller’s properties:

  3. Add a Parametrized Action to the Controller:

  4. Handle the Action’s Execute event to implement custom code:

  5. Run the application.

Detailed Explanation

Search Implementation

In XAF, you use the Object Space to query and update persistent objects. Call the static XafApplication.CreateObjectSpace method to create an Object Space.

Use the IObjectSpace.FirstOrDefault<ObjectType> method to find a DemoTask object. This method has the following parameter:

  • A lambda expression to search for an object.

Create a New View

To show the found object in a separate Detail View:

  1. Call the XafApplication.CreateDetailView method to create a View.
  2. Assign the View to the e.ShowViewParameters.CreatedView property of the event parameter.

Tip

You can initialize the ShowViewParameters property in the Execute event handler of any Action of any type. This allows you to always show a View after an Action is executed.

For more information on how to show a View in a separate window, refer to the following topic: Ways to Show a View.

Manage a Cross-Platform .NET App UI Application

Use XafApplication object when you need to create a List View, Detail View, Object Space, etc. You can access it from various locations in an XAF application. For example, to access this object from the controller, use the property.

Note

CodeRush allows you to add Actions and Controllers with a few keystrokes. To learn about the Code Templates for XAF , refer to the following help topic: XAF Templates.

Next Lesson

Add an Action that Displays a Pop-Up Window

See Also

Create, Read, Update and Delete Data

Actions (Menu Commands)

ParametrizedAction

Controllers (UI Logic & Interaction)