expressappframework-402155-getting-started-in-depth-tutorial-blazor-add-actions-menu-commands-add-a-parametrized-action.md
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:
Add a new View Controller to the MySolution.Module project, as described in the Add a Simple Action lesson. Name it FindBySubjectController.
In the MySolution.Module | Controllers | FindBySubjectController.cs file, specify the controller’s properties:
Add a Parametrized Action to the Controller:
Handle the Action’s Execute event to implement custom code:
Run the application.
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:
To show the found object in a separate Detail View:
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.
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.
Add an Action that Displays a Pop-Up Window
See Also