How to: Reorder an Action Container's Actions Collection

In an XAF application UI, Actions are located within Action Containers. You can use the ActionBase.Category property and the Application Model's ActionDesign | ActionToContainerMapping node to move the Action to another Action Container (see Place an Action in a Different Location). This topic describes how to reorder Actions within a specific container.

Presume you have the MyAction Action implemented in the MyController Controller. The ActionBase.Category property is set to View for this Action. This means that the Action is displayed within the View Action Container. This Container may also contain other Actions - custom Actions, and actions from referenced modules. To reorder Actions of the View Action Container (or any other Action Container), invoke the Model Editor for the WinForms, ASP.NET or Mobile application project. Locate the ActionDesign | ActionToContainerMapping | View node. The following image shows that there are three Actions in the View Action Container.

PlaceActionToPosition_InitialSate

To reorder these Actions, change the Index property for each Action. For instance, use the "0" value for MyAction, "1" - for Refresh, "2" - for ExecuteReport.

PlaceActionToPosition_Index

If you run the application, you can ensure that the Actions order is changed as follows.

PlaceActionToPosition_Runtime

Note
  • Actions from the Unspecified Action Container can be displayed by another container if you change the IFrameTemplate.DefaultContainer value for the current Template. These Actions are appended to the end of the collection. If you need to change their position within the Container, then first specify their Action Container explicitly.
  • In the application with the TabbedMDI UI type (see MdiShowViewStrategy), the main window's Actions collection is merged with the child window's Actions, which can influence the resulting Actions order.
Tip

To change Action Containers order and location, customize the Template. In WinForms applications, you can also use the runtime customization capabilities.

See Also