Skip to main content
A newer version of this page is available. .

ListEditor.ContextMenuTemplate Property

Provides access to a List Editor‘s Context Menu Template.

Namespace: DevExpress.ExpressApp.Editors

Assembly: DevExpress.ExpressApp.v18.2.dll

Declaration

public virtual IContextMenuTemplate ContextMenuTemplate { get; }

Property Value

Type Description
DevExpress.ExpressApp.Templates.IContextMenuTemplate

A control which implements the IContextMenuTemplate interface and represents a List Editor’s Context Menu Template.

Remarks

A List Editor can have a context menu that contains a set of Actions:

ContextMenuTemplate

The context menu can be represented by any control. However, to display Actions, it must implement the IContextMenuTemplate interface. This interface exposes the following members:

  • The IContextMenuTemplate.CreateActionItems method

    This method receives a list of Action Containers as a parameter. Each Action Container creates controls for the Actions that are mapped to it in the Application Model‘s ActionDesign | ActionToContainerMapping node.

  • The IContextMenuTemplate.BoundItemCreating event

    The event is raised when creating an Action in an Action Container. This event is used by the ActionsCriteriaViewController to determine the Action’s availability in the current context. If the Action’s availability conditions are satisfied, the ActionsCriteriaViewController sets the event argument’s BoundItemCreatingEventArgs.Enabled property to true.

A control that implements the IContextMenuTemplate interface should be created in the List Editor’s constructor, and assigned to the ContextMenuTemplate property.

The list of the Action Containers to be added to the List Editor’s Context Menu Template is specified by the Template of the currently active Window or Frame. To change the Context Menu Template’s list of Action Containers, modify the corresponding Template. For instance, the following code snippet demonstrates a part of the MainForm.Designer.cs file. The following lines specify the Action Containers for Context Menu Templates:

this.actionsContainersManager.ContextMenuContainers.Add(this.cObjectsCreation);
this.actionsContainersManager.ContextMenuContainers.Add(this.cSave);
this.actionsContainersManager.ContextMenuContainers.Add(this.cEdit);
this.actionsContainersManager.ContextMenuContainers.Add(this.cRecordEdit);
this.actionsContainersManager.ContextMenuContainers.Add(this.cOpenObject);
this.actionsContainersManager.ContextMenuContainers.Add(this.cUndoRedo);
this.actionsContainersManager.ContextMenuContainers.Add(this.cPrint);
this.actionsContainersManager.ContextMenuContainers.Add(this.cView);
this.actionsContainersManager.ContextMenuContainers.Add(this.cReports);
this.actionsContainersManager.ContextMenuContainers.Add(this.cExport);
this.actionsContainersManager.ContextMenuContainers.Add(this.cMenu);

There are two ways to assign an Action to an Action Container:

  • The first way is to use an Action’s ActionBase.Category property. This property specifies the Action Container to which the Action is assigned:

    ActionBase.Category

    If this property is not set, the Action is assigned to the Action Container used by default in a Template. Different Templates may have different default Action Containers. So, depending on the current Template, the Action may be displayed in different Action Containers.

  • The second way is to use the Model Editor. Each child node of the ActionToContainerMapping node corresponds to an Action Container and contains a list of Actions assigned to the Action Container. This list specifies all the Actions whose Category property holds the Action Container’s name:

    ActionToContainerMapping.ActionId

The following table lists built-in Context Menu Templates of the eXpressApp Framework:

Name Description
ActionsDXPopupMenu Used by the built-in Windows Forms List Editors. Represents a pop-up menu. Creates a pop-up menu item for each Action.
ASPxGridViewContextMenu Used by the built-in ASPxGridListEditor. Creates an additional grid column for each Action.
ASPxSchedulerContextMenu Used by the built-in SchedulerListEditor. Represents a pop-up menu. Creates a pop-up menu item for each Action.
DataGridContextMenu Used by the built-in Web.Editors.Standard.GridListEditor. Creates an additional grid column for each Action.

When deriving from the ListEditor class, override the ContextMenuTemplate property to return the required Context Menu Template. To see an example of how to use this property, refer to the How to: Support a Context Menu for a Custom WinForms List Editor topic.

See Also