Skip to main content
.NET Framework 4.5.2+

SingleChoiceAction.ItemType Property

Specifies the type of a Single Choice Action’s items from the ChoiceActionBase.Items collection.

Namespace: DevExpress.ExpressApp.Actions

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

[DefaultValue(SingleChoiceActionItemType.ItemIsMode)]
public SingleChoiceActionItemType ItemType { get; set; }

Property Value

Type Default Description
SingleChoiceActionItemType ItemIsMode

A SingleChoiceActionItemType enumeration value identifying a Single Choice Action’s items kind.

Remarks

Use this property to specify whether the Single Choice Action’s items represent a mode or an operation. Item type is considered when the Single Choice Action is displayed. When items represent modes, the Action’s control indicates the current selection. For items that represent operations, this functionality is not provided.

The example below demonstrates how to add a SingleChoiceAction and set it to perform operations.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;

// ...
public class SingleChoiceActionController : ObjectViewController<ListView, Person> {
    public SingleChoiceActionController() {
        SingleChoiceAction contactAction = new SingleChoiceAction(this, "ContactAction", PredefinedCategory.Edit);
        contactAction.ItemType = SingleChoiceActionItemType.ItemIsOperation;
        ChoiceActionItem openContact = new ChoiceActionItem("openContact", "Open Contact", null);
        ChoiceActionItem deleteContact = new ChoiceActionItem("deleteContact", "Delete Contact", null);
        contactAction.Items.Add(openContact);
        contactAction.Items.Add(deleteContact);
        contactAction.Execute += ContactAction_Execute;
    }
    private void ContactAction_Execute(object sender, SingleChoiceActionExecuteEventArgs e) {
        if(View.CurrentObject != null) {
            if(e.SelectedChoiceActionItem.Id == "openContact") {
                IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(Person));
                object currentObject = objectSpace.GetObject(View.CurrentObject);
                if(currentObject != null) {
                    e.ShowViewParameters.CreatedView = Application.CreateDetailView(objectSpace, currentObject);
                }
                else {
                    objectSpace.Dispose();
                }
            }
            else if(e.SelectedChoiceActionItem.Id == "deleteContact") {
                View.ObjectSpace.Delete(View.CurrentObject);
                View.ObjectSpace.CommitChanges();
                View.Refresh(true);
            }
        }
    }
}

Items represent modes

SingleChoiceAction_ItemType_Mode

Items represent operations

SingleChoiceAction_ItemType_Operation

Note

The defined behavior is provided by built-in Action Containers. You can customize this by implementing a custom Action Container.

See Also