CollectionView Class

 

Represents a view for grouping, sorting, filtering, and navigating a data collection.

Namespace:   System.Windows.Data
Assembly:  PresentationFramework (in PresentationFramework.dll)


public class CollectionView : DispatcherObject, ICollectionView, 
	IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged

NameDescription
System_CAPS_pubmethodCollectionView(IEnumerable)

Initializes a new instance of the CollectionView class that represents a view of the specified collection.

NameDescription
System_CAPS_protpropertyAllowsCrossThreadChanges

Gets a value that indicates whether a thread other than the one that created the CollectionView can change the SourceCollection.

System_CAPS_pubpropertyCanFilter

Gets a value that indicates whether the view supports filtering.

System_CAPS_pubpropertyCanGroup

Gets a value that indicates whether the view supports grouping.

System_CAPS_pubpropertyCanSort

Gets a value that indicates whether the view supports sorting.

System_CAPS_pubpropertyComparer

Returns an object that you can use to compare items in the view.

System_CAPS_pubpropertyCount

Gets the number of records in the view.

System_CAPS_pubpropertyCulture

Gets or sets the culture information to use during sorting.

System_CAPS_pubpropertyCurrentItem

Gets the current item in the view.

System_CAPS_pubpropertyCurrentPosition

Gets the ordinal position of the CurrentItem within the (optionally sorted and filtered) view.

System_CAPS_pubpropertyDispatcher

Gets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)

System_CAPS_pubpropertyFilter

Gets or sets a method used to determine if an item is suitable for inclusion in the view.

System_CAPS_pubpropertyGroupDescriptions

Gets a collection of GroupDescription objects that describes how the items in the collection are grouped in the view.

System_CAPS_pubpropertyGroups

Gets a collection of the top-level groups that is constructed based on the GroupDescriptions property.

System_CAPS_pubpropertyIsCurrentAfterLast

Gets a value that indicates whether the CurrentItem of the view is beyond the end of the collection.

System_CAPS_pubpropertyIsCurrentBeforeFirst

Gets a value that indicates whether the CurrentItem of the view is before the beginning of the collection.

System_CAPS_protpropertyIsCurrentInSync

Gets a value that indicates whether the CurrentItem is at the CurrentPosition.

System_CAPS_protpropertyIsDynamic

Gets a value that indicates whether the underlying collection provides change notifications.

System_CAPS_pubpropertyIsEmpty

Gets a value that indicates whether the resulting (filtered) view is empty.

System_CAPS_pubpropertyIsInUse

Gets a value that indicates whether any object is subscribing to the events of this CollectionView.

System_CAPS_protpropertyIsRefreshDeferred

Gets a value that indicates whether there is an outstanding DeferRefresh in use.

System_CAPS_pubpropertyNeedsRefresh

Gets a value that indicates whether the view needs to be refreshed.

System_CAPS_pubpropertySystem_CAPS_staticNewItemPlaceholder

Gets the object that is in the collection to represent a new item.

System_CAPS_pubpropertySortDescriptions

Gets a collection of SortDescription structures that describes how the items in the collection are sorted in the view.

System_CAPS_pubpropertySourceCollection

Returns the underlying unfiltered collection.

System_CAPS_protpropertyUpdatedOutsideDispatcher

Gets a value that indicates whether it has been necessary to update the change log because a CollectionChanged notification has been received on a different thread without first entering the user interface (UI) thread dispatcher.

NameDescription
System_CAPS_pubmethodCheckAccess()

Determines whether the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.)

System_CAPS_protmethodClearChangeLog()

Obsolete.Clears any pending changes from the change log.

System_CAPS_protmethodClearPendingChanges()

Clears unprocessed changed to the collection.

System_CAPS_pubmethodContains(Object)

Returns a value that indicates whether the specified item belongs to the view.

System_CAPS_pubmethodDeferRefresh()

Enters a defer cycle that you can use to merge changes to the view and delay automatic refresh.

System_CAPS_pubmethodDetachFromSourceCollection()

Removes the reference to the underlying collection from the CollectionView.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_protmethodGetEnumerator()

Returns an object that you can use to enumerate the items in the view.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetItemAt(Int32)

Retrieves the item at the specified zero-based index in the view.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodIndexOf(Object)

Returns the index at which the specified item is located.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodMoveCurrentTo(Object)

Sets the specified item to be the CurrentItem in the view.

System_CAPS_pubmethodMoveCurrentToFirst()

Sets the first item in the view as the CurrentItem.

System_CAPS_pubmethodMoveCurrentToLast()

Sets the last item in the view as the CurrentItem.

System_CAPS_pubmethodMoveCurrentToNext()

Sets the item after the CurrentItem in the view as the CurrentItem.

System_CAPS_pubmethodMoveCurrentToPosition(Int32)

Sets the item at the specified index to be the CurrentItem in the view.

System_CAPS_pubmethodMoveCurrentToPrevious()

Sets the item before the CurrentItem in the view as the CurrentItem.

System_CAPS_protmethodOKToChangeCurrent()

Returns a value that indicates whether the view can change which item is the CurrentItem.

System_CAPS_protmethodOnAllowsCrossThreadChangesChanged()

Occurs when the AllowsCrossThreadChanges property changes.

System_CAPS_protmethodOnBeginChangeLogging(NotifyCollectionChangedEventArgs)

Obsolete.Called by the base class to notify the derived class that an INotifyCollectionChanged.CollectionChanged event has been posted to the message queue.

System_CAPS_protmethodOnCollectionChanged(NotifyCollectionChangedEventArgs)

Raises the CollectionChanged event.

System_CAPS_protmethodOnCollectionChanged(Object, NotifyCollectionChangedEventArgs)

Raises the CollectionChanged event.

System_CAPS_protmethodOnCurrentChanged()

Raises the CurrentChanged event.

System_CAPS_protmethodOnCurrentChanging()

Raises a CurrentChanging event that is not cancelable.

System_CAPS_protmethodOnCurrentChanging(CurrentChangingEventArgs)

Raises the CurrentChanging event with the specified arguments.

System_CAPS_protmethodOnPropertyChanged(PropertyChangedEventArgs)

Raises the PropertyChanged event using the specified arguments.

System_CAPS_pubmethodPassesFilter(Object)

Returns a value that indicates whether the specified item in the underlying collection belongs to the view.

System_CAPS_protmethodProcessCollectionChanged(NotifyCollectionChangedEventArgs)

When overridden in a derived class, processes a single change on the UI thread.

System_CAPS_protmethodProcessPendingChanges()

System_CAPS_pubmethodRefresh()

Re-creates the view.

System_CAPS_protmethodRefreshOrDefer()

Refreshes the view or specifies that the view needs to be refreshed when the defer cycle completes.

System_CAPS_protmethodRefreshOverride()

Re-creates the view.

System_CAPS_protmethodSetCurrent(Object, Int32)

Sets the specified item and index as the values of the CurrentItem and CurrentPosition properties.

System_CAPS_protmethodSetCurrent(Object, Int32, Int32)

Sets the specified item and index as the values of the CurrentItem and CurrentPosition properties. This method can be called from a constructor of a derived class.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodVerifyAccess()

Enforces that the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.)

NameDescription
System_CAPS_proteventCollectionChanged

Occurs when the view has changed.

System_CAPS_pubeventCurrentChanged

Occurs after the CurrentItem has changed.

System_CAPS_pubeventCurrentChanging

Occurs when the CurrentItem is changing.

System_CAPS_proteventPropertyChanged

Occurs when a property value has changed.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_priveventINotifyCollectionChanged.CollectionChanged

Occurs when the view has changed.

System_CAPS_pubinterfaceSystem_CAPS_priveventINotifyPropertyChanged.PropertyChanged

Occurs when a property value changes.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable.GetEnumerator()

Returns an IEnumerator object that you can use to enumerate the items in the view.

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<TResult>()

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

You should not create objects of this class in your code. To create a collection view for a collection that only implements IEnumerable, create a CollectionViewSource object, add your collection to the Source property, and get the collection view from the View property.

You can think of a collection view as a layer on top of a binding source collection that allows you to navigate and display the collection based on sort, filter, and group queries, all without having to manipulate the underlying source collection itself. If the source collection implements the INotifyCollectionChanged interface, the changes that raise the CollectionChanged event are propagated to the views.

Because a view does not change the underlying source collection, a source collection can have multiple views associated with it. By using views, you can display the same data in different ways. For example, you can use two views on a collection of Task objects to show tasks sorted by priority on one part of the page and grouped by area on another part of the page.

In WPF applications, all collections have an associated default collection view. Rather than working with the collection directly, the binding engine always accesses the collection through the associated view. To get the default view, use the CollectionViewSource.GetDefaultView method. An internal class based on CollectionView is the default view for collections that implement only IEnumerable. ListCollectionView is the default view for collections that implement IList. BindingListCollectionView is the default view for collections that implement IBindingListView or IBindingList.

Alternatively, you can create a view of your collection in Extensible Application Markup Language (XAML) by using the CollectionViewSource class and then bind your control to that view. The CollectionViewSource class is the XAML representation of the CollectionView class. For an example, see How to: Sort and Group Data Using a View in XAML.

For more information, see "Binding to Collections" in Data Binding Overview.

To set a view in XAML, use the CollectionViewSource class. CollectionViewSource is the XAML representation of the CollectionView class, and it exposes the most commonly used members of the CollectionView class.

See Remarks

.NET Framework
Available since 3.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: