0 out of 5 rated this helpful - Rate this topic

CollectionViewSource Class

April 12, 2014

The XAML proxy of a collection view class.

System.Object
  System.Windows.DependencyObject
    System.Windows.Data.CollectionViewSource

Namespace:  System.Windows.Data
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
public class CollectionViewSource : DependencyObject, 
	ISupportInitialize
<CollectionViewSource .../>

The CollectionViewSource type exposes the following members.

  NameDescription
Public methodCollectionViewSourceInitializes a new instance of the CollectionViewSource class.
Top
  NameDescription
Public propertyCultureGets or sets the cultural information for any operations of the view that might differ by culture, such as sorting.
Public propertyDispatcherGets the Dispatcher this object is associated with. (Inherited from DependencyObject.)
Public propertyGroupDescriptionsGets a collection of GroupDescription objects that describe how items in the collection are grouped in the view.
Public propertySortDescriptionsGets a collection of SortDescription objects that describe how the items in the collection are sorted in the view.
Public propertySourceGets or sets the collection object from which to create this view.
Public propertyViewGets the view object that is currently associated with this instance of CollectionViewSource.
Top
  NameDescription
Public methodCheckAccessDetermines whether the calling thread has access to this object. (Inherited from DependencyObject.)
Public methodClearValueClears the local value of a dependency property. (Inherited from DependencyObject.)
Public methodDeferRefreshEnters a defer cycle that you can use to merge changes to the view and delay automatic refresh.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetAnimationBaseValueReturns any base value established for a Windows Phone dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetValueReturns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnCollectionViewTypeChangedInvoked when the collection view type changes.
Protected methodOnSourceChangedInvoked when the Source property changes.
Public methodReadLocalValueReturns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)
Public methodSetValueSets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top
  NameDescription
Public eventFilterProvides filtering logic.
Top
  NameDescription
Public fieldStatic memberSourcePropertyIdentifies the Source dependency property.
Public fieldStatic memberViewPropertyIdentifies the View dependency property.
Top
  NameDescription
Explicit interface implemetationPrivate methodISupportInitialize.BeginInitSignals the object that initialization is starting.
Explicit interface implemetationPrivate methodISupportInitialize.EndInitSignals the object that initialization is complete.
Top

CollectionViewSource is a proxy for a class that implements ICollectionView. CollectionViewSource enables XAML code to set the commonly used ICollectionView properties, passing these settings to the underlying view. CollectionViewSource has a View property that holds the actual view and a Source property that holds the source collection. The view is generated automatically unless the source collection implements ICollectionViewFactory, in which case the view is retrieved through the CreateView method.

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

Because views do not change the underlying source collections, each source collection can have multiple views associated with it. For example, you may have a collection of Task objects. With the use of views, you can display that same data in different ways. For example, on the left side of your page you may want to show tasks sorted by priority, and on the right side, grouped by area.

The following code example demonstrates the use of this class in XAML to apply sorting to a data source. The data is also defined in XAML to enable you to see the effects of the CollectionViewSource in the interface designer in Visual Studio 2010.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.