Skip to main content
.NET 6.0+

CollectionSourceBase.Collection Property

Provides access to the Collection Source’s (see CollectionSourceBase) collection of objects.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v23.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public object Collection { get; }

Property Value

Type Description
Object

An object representing the Collection Source’s collection of objects.

Remarks

Use this property to access the Collection Source’s collection. A Collection Source’s Collection holds the objects retrieved from a data source by an Object Space and displayed by a List View in a UI. You may need to access a Collection Source’s collection, for example, to filter a List View on the data source level. To learn how to do it, refer to the Criteria Property of a List View’s Collection Source topic.

The following table lists the events related to the Collection Source’s collection.

Event Description
CollectionSourceBase.CollectionChanging Occurs before the collection has been recreated.
CollectionSourceBase.CollectionChanged Occurs after the collection has been recreated.
CollectionSourceBase.CollectionReloading Occurs before the collection has been reloaded.
CollectionSourceBase.CollectionReloaded Occurs after the collection has been reloaded.
CollectionSourceBase.CriteriaApplying Occurs before the collection has been filtered using the criteria defined in the CollectionSourceBase.Criteria dictionary.
CollectionSourceBase.CriteriaApplied Occurs after the collection has been filtered using the criteria defined in the CollectionSourceBase.Criteria dictionary.

Note, that while View Controllers are activating for a List View, the List View’s CollectionSourceBase.Collection property may return null. So, if you need to access a Collection Source’s collection in a View Controller, do not perform the collection-dependent code after the Controller has been activated. Instead, subscribe to the CollectionSourceBase.CollectionChanged event, and perform your code in the event handler.

If the object returned by this property does not implement the IEnumerable interface, but you need to iterated through the retrieved objects, use the CollectionSourceBase.List property.

Be aware in which mode the current Collection’s Collection Source is created: CollectionSourceBase.DataAccessMode and CollectionSourceBase.Mode. This influences which objects are currently retrieved to the Collection.

See Also