Holds the list of items that constitute the content of an ItemsControl.
Assembly: PresentationFramework (in PresentationFramework.dll)
maintains a collection of items such as strings, objects, XML nodes, elements, and other collections. An ItemsControl uses the data in the to generate its content. If you want to aggregate more than one collection, assign a CompositeCollection to the ItemsSource property of your ItemsControl.
Use either the Items property or the ItemsSource property to specify the collection that should be used to generate the content of your ItemsControl. When the ItemsSource property is set, the Items collection will be made read-only and fixed-size. This means that if you are using the ItemsSource property, you cannot add, delete, or change items in the directly.
For more information about collection views, see Data Binding Overview.
If you have an ItemsControl, such as a ListBox that has content, you can use the Items property to access the , which is a view. Because it is a view, you can then use the view-related functionalities such as sorting, filtering, and grouping. Note that when ItemsSource is set, the view operations delegate to the view over the ItemsSource collection. Therefore, the ItemCollection supports sorting, filtering, and grouping only if the delegated view supported them.
The following example shows how to sort the content of a ListBox named myListBox. In this example, Content is the name of the property to sort by.
When you do this, the view might or might not be the default view, depending on how the data is set up on your ItemsControl. For example, when the ItemsSource property is bound to a CollectionViewSource, the view that you obtain using the Items property is not the default view.
Alternately, you can specify filtering, sorting, and grouping criteria in XAML using CollectionViewSource.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.