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.
Syntax
Public Property Source As Object
public Object Source { get; set; }
<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 nullNothingnullptra null reference (Nothing in Visual Basic).
Exceptions
| Exception | Condition |
|---|---|
| ArgumentException | The specified value when setting this property is not nullNothingnullptra null reference (Nothing in Visual Basic) 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:
|
Remarks
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.
Examples
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.
Version Information
Windows Phone OS
Supported in: 8.1, 8.0, 7.1, 7.0
Platforms
Windows Phone