Skip to main content
.NET Framework 4.5.2+

XafApplication.CreateListView(IObjectSpace, Type, Boolean) Method

Creates a List View used for the objects of the specified type, by default.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public ListView CreateListView(
    IObjectSpace objectSpace,
    Type objectType,
    bool isRoot
)

Parameters

Name Type Description
objectSpace IObjectSpace

An IObjectSpace object representing the Object Space used to retrieve objects from the database to the created List View’s Collection Source.

objectType Type

A Type object specifying the business object type.

isRoot Boolean

true, if the created List View is independent and owns the Object Space passed using the objectSpace parameter; false if the created List View is nested to another root View that owns the Object Space. This value is assigned to the View.IsRoot property.

Returns

Type Description
ListView

A ListView object used to display the collection of objectType objects.

Remarks

If you need to create a List View using the information specified in the Application Model, use other CreateListView method overloads.

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 following example creates a List View and displays it via a PopupWindowShowAction.

using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
// ...
public class ShowListViewController : WindowController {
    public ShowListViewController() {
        PopupWindowShowAction showListViewAction = new PopupWindowShowAction(
            this, "ShowListView", PredefinedCategory.Edit);
        showListViewAction.CustomizePopupWindowParams += ShowListViewAction_CustomizePopupWindowParams;
    }
    private void ShowListViewAction_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e) {
        Type objectType = typeof(Person);
        IObjectSpace newObjectSpace = Application.CreateObjectSpace(objectType);
        e.View = Application.CreateListView(newObjectSpace, objectType, true);
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CreateListView(IObjectSpace, Type, Boolean) 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