Skip to main content
.NET Framework 4.5.2+

CloneObjectViewController.CustomGetCloneActionTargetTypes Event

Occurs before getting the target types list, available via the CloneObjectViewController.CloneObjectAction.

Namespace: DevExpress.ExpressApp.CloneObject

Assembly: DevExpress.ExpressApp.CloneObject.Xpo.v24.1.dll

Declaration

public event EventHandler<CustomGetCloneActionTargetTypesEventArgs> CustomGetCloneActionTargetTypes

Event Data

The CustomGetCloneActionTargetTypes event's data class is CustomGetCloneActionTargetTypesEventArgs. The following properties provide information specific to this event:

Property Description
Handled Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing. Inherited from HandledEventArgs.
SourceType Gets the type of the source object to be cloned.
TargetTypes Gets the System.Collections.Generic.Dictonary object representing the collection of target types and their corresponding IModelNode nodes.

The event data class exposes the following methods:

Method Description
GetDefaultTargetTypes() Returns the default target types of the CloneObjectViewController.CloneObjectAction.

Remarks

Handle the CustomGetCloneActionTargetTypes event to add custom target types via the handler’s TargetTypes property. To prohibit adding the default target types, set the handler’s Handled parameter to true.

By default, the CloneObject Action‘s ChoiceActionBase.Items collection includes the current object type and types inherited from the current object’s base class. To get a list of these types in a CustomGetCloneActionTargetTypes handler, use the CustomGetCloneActionTargetTypesEventArgs.GetDefaultTargetTypes method.

The following code demonstrates how to prohibit adding descendant types of the current object type’s base type to the Action’s ChoiceActionBase.Items collection:

using DevExpress.ExpressApp.CloneObject;
//...
public class MyCloneObjectController : CloneObjectViewController {
    // ...
    protected override void OnActivated() {
        this.CustomGetCloneActionTargetTypes += 
            MyCloneObjectController_CustomGetCloneActionTargetTypes;
        base.OnActivated();
    }
    private void MyCloneObjectController_CustomGetCloneActionTargetTypes(
        object sender, CustomGetCloneActionTargetTypesEventArgs e) {
        e.Handled = true;
        e.TargetTypes.Clear();
        e.TargetTypes.Add(
            Application.Model.BOModel[View.ObjectTypeInfo.Type.FullName],
            View.ObjectTypeInfo.Type);
    }
}

With the code above, the CloneObject Action will clone the currently selected object to the object of the same type, because only the Action’s Item will be the current object type. Note that the CustomGetCloneActionTargetTypes event subscription is performed before calling the base OnActivated method. This is done because CustomGetCloneActionTargetTypes is raised from OnActivated. If you want to handle this event from a Controller that is not inherited from the CloneObjectViewController, subscribe in the OnFrameAssigned method.

Alternatively, you can manually fill the Items of the CloneObjectAction by accessing this Action in the Controller’s OnActivated method. Refer to the CloneObjectViewController.CloneObjectAction topic to see an example.

See Also