XafApplication.CreateDetailView(IObjectSpace, String, Boolean) Method
Creates a Detail View based on information from the Application Model‘s Views | DetailView node specified by the detailViewID parameter.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v24.1.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Parameters
Name | Type | Description |
---|---|---|
objectSpace | IObjectSpace | An IObjectSpace object representing the Object Space which is used to work with the new Detail View DetailView.CurrentObject. This object is assigned to the View.ObjectSpace property. |
detailViewID | String | A string that represents an identifier of the Application Model node that serves as an information source for creating a new Detail View. |
isRoot | Boolean | true, if the created Detail View is independent and owns the Object Space passed using the objectSpace parameter; false, if the created Detail View is nested to another root View that owns the Object Space. This value is assigned to the View.IsRoot property. |
Returns
Type | Description |
---|---|
DetailView | A Detail View that does not represent any object. |
Remarks
Use this method to create a Detail View that is not bound to an object. You can set an object separately using the DetailView.CurrentObject property.
The detailViewID parameter should be equal the Id property of an existing IModelDetailView node from the Application Model’s Views node. If your Application Model contains several DetailView models of a certain business class, use this parameter to define which model should be used for the created View.
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.
Note
Do not use another View’s View.ObjectSpace for the creation of a new root View in it. Instead, create a new Object Space using the XafApplication.CreateObjectSpace method for the new root 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.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
//...
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) {
Type objectType = currentObject.GetType();
string detailViewId = Application.GetDetailViewId(objectType);
DetailView createdView = Application.CreateDetailView(objectSpace, detailViewId, true);
createdView.CurrentObject = currentObject;
e.View = createdView;
}
else {
objectSpace.Dispose();
}
}
}