ActionControlsSiteController.CustomizeContainerActions Event
Occurs when Actions are added to the Action Containers according to the information specified in the ActionDesign | ActionToContainerMapping Application Model node.
Namespace: DevExpress.ExpressApp.SystemModule
Assembly: DevExpress.ExpressApp.v24.2.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Event Data
The CustomizeContainerActions event's data class is DevExpress.ExpressApp.SystemModule.CustomizeContainerActionsEventArgs.
Remarks
Handle the CustomizeContainerActions event to customize the action-to-container mapping in code, without making changes in the Application Model. To do the same for Templates that does not support the IActionControlsSite interface, additionally handle the FillActionContainersController.CustomizeContainerActions event. The following code demonstrates how to remove the SaveAndNew Action from the Save container and add it to the Edit container:
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.SystemModule;
using DevExpress.ExpressApp.Win.Templates.Bars.ActionControls;
// ...
public class CustomizeContainerActionsController : Controller {
protected override void OnActivated() {
base.OnActivated();
Frame.GetController<ActionControlsSiteController>().CustomizeContainerActions += OnCustomizeContainerActions;
Frame.GetController<FillActionContainersController>().CustomizeContainerActions += OnCustomizeContainerActions;
}
protected override void OnDeactivated() {
Frame.GetController<ActionControlsSiteController>().CustomizeContainerActions -= OnCustomizeContainerActions;
Frame.GetController<FillActionContainersController>().CustomizeContainerActions -= OnCustomizeContainerActions;
base.OnDeactivated();
}
private void OnCustomizeContainerActions(object sender, CustomizeContainerActionsEventArgs e) {
ActionBase actionToBeMoved = e.AllActions.Find("SaveAndNew");
if ((actionToBeMoved != null) && (e.Category == "Save") && (e.Container is BarLinkActionControlContainer)) {
e.ContainerActions.Remove(actionToBeMoved);
}
if ((actionToBeMoved != null) && (e.Category == "Edit")) {
e.ContainerActions.Add(actionToBeMoved);
}
}
}
The result is demonstrated in the image below: