XafApplication.CreateDetailView(IObjectSpace, IModelDetailView, Boolean, Object) Method
Creates a Detail View for the specified object with settings from the Application Model‘s Views | DetailView node specified by the modelDetailView parameter.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v24.2.dll
NuGet Package: DevExpress.ExpressApp
#Declaration
public DetailView CreateDetailView(
IObjectSpace objectSpace,
IModelDetailView modelDetailView,
bool isRoot,
object obj
)
#Parameters
Name | Type | Description |
---|---|---|
object |
IObject |
An IObject |
model |
IModel |
An IModel |
is |
Boolean | true, if the created Detail View is independent and owns the Object Space passed using the object |
obj | Object | An object which is represented by the new Detail View. This object is assigned to the Detail |
#Returns
Type | Description |
---|---|
Detail |
A Detail View that represents the object passed as the obj parameter. |
#Remarks
Use this method to create and initialize a Detail View according to values passed as parameters.
If your Application Model contains several DetailView models of a certain business class, use the modelDetailView parameter to define which model should be used for the created View. To get the default model, use the IModelClass.DefaultDetailView property.
Pass true to the isRoot parameter if the new View owns the Object Space passed to the objectSpace parameter. If this Object Space already belongs to another View, pass false. Note that certain Controllers and Actions are deactivated in this case. See View.IsRoot for additional information. To avoid this, use the XafApplication.CreateObjectSpace or XafApplication.CreateNestedObjectSpace method to create a new Object Space, and pass this Object Space to the objectSpace parameter.
The object specified in the obj parameter should belong to the Object Space specified in the objectSpace parameter. To pass an object from another Object Space to this Object Space, use the IObjectSpace.GetObject method.
Note
Do not use another View’s View.
The example below demonstrates how to open an object’s Detail View via a PopupWindowShowAction.
using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Model;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
// ...
public class ShowDetailViewController : ObjectViewController<ListView, Person> {
public ShowDetailViewController() {
PopupWindowShowAction showDetailViewAction = new PopupWindowShowAction(
this, "ShowDetailView", PredefinedCategory.Edit);
showDetailViewAction.SelectionDependencyType = SelectionDependencyType.RequireSingleObject;
showDetailViewAction.CustomizePopupWindowParams += ShowDetailViewAction_CustomizePopupWindowParams;
}
private void ShowDetailViewAction_CustomizePopupWindowParams(
object sender, CustomizePopupWindowParamsEventArgs e) {
IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(Person));
Object currentObject = objectSpace.GetObject(View.CurrentObject);
if(currentObject != null) {
IModelClass modelClass = Application.FindModelClass(currentObject.GetType());
IModelDetailView defaultDetailView = modelClass.DefaultDetailView;
e.View = Application.CreateDetailView(objectSpace, defaultDetailView, true, currentObject);
}
else {
objectSpace.Dispose();
}
}
}