XafApplication.DetailViewCreating Event
Occurs when creating a Detail View.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v24.2.dll
NuGet Package: DevExpress.ExpressApp
#Declaration
public event EventHandler<DetailViewCreatingEventArgs> DetailViewCreating
#Event Data
The DetailViewCreating event's data class is DetailViewCreatingEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Enable |
For internal use. Use the Detail |
Is |
Indicates whether a root View must be created.
Inherited from View |
Obj | Returns the object that represents a current object for the Detail View to be the created. |
Object |
Returns the Object Space to be used when creating a new View.
Inherited from View |
View |
Specifies the Detail View which is created in the Xaf |
View |
Returns the ID of the created View.
Inherited from View |
#Remarks
Handle this event to provide a custom Detail View instead of a default one. Use the handler’s ViewCreatingEventArgs.ViewID parameter to get information on the created Detail View. To do this use the application’s XafApplication.FindModelView method passing the View ID as a parameter. To specify the Detail View’s current object use the handler’s DetailViewCreatingEventArgs.Obj parameter. Create the Detail View in the Object Space passed as the handler’s ViewCreatingEventArgs.ObjectSpace parameter.
The following example demonstrates how to handle the DetailViewCreating
event to select a DetailView model based on properties of a displayed object:
using DevExpress.ExpressApp;
// using MainDemo.Module.BusinessObjects;
public class EmployeeDetailViewModelController : WindowController {
public EmployeeDetailViewModelController() {
TargetWindowType = WindowType.Main;
}
protected override void OnActivated() {
base.OnActivated();
Application.DetailViewCreating += Application_DetailViewCreating;
}
private void Application_DetailViewCreating(object sender, DetailViewCreatingEventArgs e) {
if (e.ViewID == "Employee_DetailView" && e.Obj is Employee employee && employee.Position?.Title == "Manager") {
e.ViewID = "Employee_DetailView_Manager";
}
}
protected override void OnDeactivated() {
base.OnDeactivated();
Application.DetailViewCreating -= Application_DetailViewCreating;
}
}
Note
If Detail
- when you open a Detail View from the Navigation, the Detail
View argument of theCreating Event Args. Obj Detail
event is set to null;View Creating - when you open a Detail View from a List View (by double-clicking a record or using the Open
Object Action), the DetailView argument of theCreating Event Args. Obj Detail
event is set to the object from the List View’s Object Space.View Creating