XafApplication.CreateListView(IModelListView, CollectionSourceBase, Boolean) Method
Creates a List View based on the information from the Application Model‘s node specified by the modelListView parameter.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v24.2.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Parameters
Name | Type | Description |
---|---|---|
modelListView | IModelListView | An IModelListView object that represents the Application Model node that serves as an information source for creating a new List View. |
collectionSource | CollectionSourceBase | A CollectionSourceBase object that represents the storage for the object to be displayed by the new List View. This object is assigned to the ListView.CollectionSource property. |
isRoot | Boolean | true, if the created List View is independent and owns the Object Space assigned to the View.ObjectSpace property; 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 objects specified by the collectionSource parameter. |
Remarks
Use this method to create and initialize a List View according to values passed as parameters.
To create a Collection Source for the collectionSource parameter, use the XafApplication.CreateCollectionSource method. The created Collection Source can be customized to change objects displayed in the created List View. For example, the List View’s records can be filtered through the CollectionSourceBase.Criteria property. With this CreateListView overload, the View.ObjectSpace property is initialized using the CollectionSourceBase.ObjectSpace value.
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 Lookup List View and displays it 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 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);
string listViewId = Application.FindLookupListViewId(objectType);
IModelListView modelListView = (IModelListView)Application.FindModelView(listViewId);
CollectionSourceBase collectionSource = Application.CreateCollectionSource(
newObjectSpace, objectType, listViewId);
e.View = Application.CreateListView(modelListView, collectionSource, true);
}
}