Skip to main content
.NET Framework 4.6.2+

XafApplication.CreateDetailView(IObjectSpace, Object, View) Method

Creates a Detail View for a specified object based on information on the source View.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public DetailView CreateDetailView(
    IObjectSpace objectSpace,
    object obj,
    View sourceView
)

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.

obj Object

An object which is represented by the new Detail View. This object is assigned to the DetailView.CurrentObject property.

sourceView View

A View object that represents the View in which the command to show the new Detail View has been performed.

Returns

Type Description
DetailView

A Detail View that represents the object passed as the obj parameter.

Remarks

If the new Detail View‘s View.ObjectSpace is different from the source View’s Object Space, its View.IsRoot property is set to true. Note that certain Controllers and Actions are deactivated if the IsRoot property is set to false. To avoid this, use the XafApplication.CreateObjectSpace or XafApplication.CreateNestedObjectSpace method to create a new Object Space, and pass this Object Space as 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.

Use this overload when you need information on the source View to determine what Detail View to create. Pass the source View as the sourceView parameter. If the source View is a DetailView, the method uses information from the Application Model‘s Views | <View> node to create a new Detail View. If the source View is a List View, the method retrieves the Application Model’s node information from the List View’s ListView.DetailViewId property.

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 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) {
            e.View = Application.CreateDetailView(objectSpace, currentObject, View);
        }
        else {
            objectSpace.Dispose();
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CreateDetailView(IObjectSpace, Object, View) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also