Export (0) Print
Expand All

ItemsControl::ItemsSource Property

Gets or sets a collection used to generate the content of the ItemsControl.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

[BindableAttribute(true)]
public:
property IEnumerable^ ItemsSource {
	IEnumerable^ get ();
	void set (IEnumerable^ value);
}
<object ItemsSource="bindingDeclaration"/>

XAML Values

bindingDeclaration

A Binding declaration. See Binding Markup Extension for more information.

Property Value

Type: System.Collections::IEnumerable
A collection that is used to generate the content of the ItemsControl. The default is nullptr.

Identifier field

ItemsSourceProperty

Metadata properties set to true

None

Content Model: This property may be used to add items to an ItemsControl.

A common scenario is to use an ItemsControl such as a ListBox, ListView, or TreeView to display a data collection, or to bind an ItemsControl to a collection object. To bind an ItemsControl to a collection object, use the ItemsSource property. Note that the ItemsSource property supports OneWay binding by default.

When the ItemsSource property is set, the Items collection is made read-only and fixed-size.

When ItemsSource is in use, setting the property to nullptr removes the collection and restores usage to Items, which will be an empty ItemCollection. When ItemsSource is not in use, the value of this property is nullptr, and setting it to nullptr has no effect.

NoteNote

In most cases you do not need to implement your own collections. Instead, consider using ObservableCollection<T> or other existing collections. For more information, see the "Collection Objects Used as Binding Source" in Binding Sources Overview.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft