CloneObjectViewController.CustomShowClonedObject Event
Occurs before XAF displays the Detail View of the cloned object.
Namespace: DevExpress.ExpressApp.CloneObject
Assembly: DevExpress.ExpressApp.CloneObject.v25.1.dll
NuGet Package: DevExpress.ExpressApp.CloneObject
#Declaration
public event EventHandler<CustomShowClonedObjectEventArgs> CustomShowClonedObject
#Event Data
The CustomShowClonedObject event's data class is CustomShowClonedObjectEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cloned |
Gets the target cloned object. |
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 Handled |
Show |
Gets a set of parameters used to display a cloned object’s Detail View. |
Source |
Gets the source cloned object. |
Target |
Specifies the Object Space of the target cloned object. |
#Remarks
XAF displays the Detail View of the cloned object after cloning. Handle this event to implement the custom code to be executed before or instead of displaying the Detail View. Set the handler’s Handled
parameter to true
to prohibit displaying the Detail View.
The following code snippet adds the cloned object to the current List View instead of displaying it in the Detail View. Note that the code only works when the current View is an editable List View. The default behavior persists when the current View is a Detail View or non-editable List View.
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.CloneObject;
using DevExpress.Persistent.BaseImpl.EF;
using Microsoft.EntityFrameworkCore.Metadata;
namespace YourApplicationName.Module.Controllers;
public class MyCloneObjectController : CloneObjectViewController {
// ...
protected override void OnActivated() {
base.OnActivated();
this.CustomShowClonedObject +=
new EventHandler<CustomShowClonedObjectEventArgs>(
MyCloneObjectController_CustomShowClonedObject);
}
private void MyCloneObjectController_CustomShowClonedObject(
object sender, CustomShowClonedObjectEventArgs e) {
if ((View is ListView) && (View.AllowEdit.ResultValue)) {
e.TargetObjectSpace.CommitChanges();
((ListView)View).CollectionSource.Add(ObjectSpace.GetObject(e.ClonedObject));
e.Handled = true;
}
}
}