How to: Create and Show a Detail View of the Selected Object in a Popup Window

This topic demonstrates a View Controller that creates and shows a Detail View of the List View's selected object in a popup window.

Follow the steps below.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Editors;
using DevExpress.Persistent.Base;
//...
public class ShowDetailViewController : ViewController<ListView> {
    public ShowDetailViewController() {
        PopupWindowShowAction showDetailViewAction = new PopupWindowShowAction(
            this, "ShowDetailView", PredefinedCategory.Edit);
        showDetailViewAction.SelectionDependencyType = SelectionDependencyType.RequireSingleObject;
        showDetailViewAction.TargetObjectsCriteria = "Not IsNewObject(This)";
        showDetailViewAction.CustomizePopupWindowParams += showDetailViewAction_CustomizePopupWindowParams;
    }
    void showDetailViewAction_CustomizePopupWindowParams(
        object sender, CustomizePopupWindowParamsEventArgs e) {
        IObjectSpace newObjectSpace = Application.CreateObjectSpace(View.ObjectTypeInfo.Type);
        Object objectToShow = newObjectSpace.GetObject(View.CurrentObject);
        if (objectToShow != null) {
            DetailView createdView = Application.CreateDetailView(newObjectSpace, objectToShow);
            createdView.ViewEditMode = ViewEditMode.Edit;
            e.View = createdView;
        }
    }
}

In this example, the root Detail View is created using an individual Object Space. The root View contains the Save Action and users can explicitly commit changes. You can customize this behavior using the CreateDetailView method overload with the isRoot parameter, or by providing a nested or existing Object Space instead of a new one. Refer to the View.IsRoot property documentation to learn more.

See Also