Source Property
Collapse the table of content
Expand the table of content

CollectionViewSource.Source Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets the collection object from which to create this view.

Namespace:  System.Windows.Data
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

'Declaration
Public Property Source As Object
<collectionViewSource>
  <collectionViewSource.Source>
    <Object .../>
  </collectionViewSource.Source>
</collectionViewSource>
<collectionViewSource Source="myCollection"/>

XAML Values

Term

Definition

myCollection

An existing collection. To refer to an existing collection, use the StaticResource markup extension.

Property Value

Type: System.Object
The collection object from which to create this view. The default is Nothing.

ExceptionCondition
ArgumentException

The specified value when setting this property is not Nothing or an IEnumerable implementation.

-or-

The specified value when setting this property is an ICollectionView implementation.

InvalidOperationException

The specified value implements ICollectionViewFactory but its CreateView method returns an ICollectionView with one or more of the following inconsistencies:

When you set this property, a view is generated automatically unless the source collection implements ICollectionViewFactory. Otherwise, the view is retrieved through the CreateView method.

You can retrieve the view through the View property.

The following code example demonstrates the use of this property 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

Show:
© 2017 Microsoft