ItemsControl.ItemsSource 屬性

定義

取得或設定用來產生 ItemsControl內容的物件來源。

public:
 property Platform::Object ^ ItemsSource { Platform::Object ^ get(); void set(Platform::Object ^ value); };
IInspectable ItemsSource();

void ItemsSource(IInspectable value);
public object ItemsSource { get; set; }
var object = itemsControl.itemsSource;
itemsControl.itemsSource = object;
Public Property ItemsSource As Object
<itemsControl ItemsSource="bindingDeclaration"/>
-or-
<itemsControl ItemsSource="resourceReferenceToSource"/>

屬性值

Object

Platform::Object

IInspectable

物件,用來產生 ItemsControl的內容。 預設值為 null

備註

您設定 ItemsSource 屬性的物件類型必須實作下列其中一個介面。

.NET C++/WinRT C++/CX
IEnumerable < 物件> IIterable<IInspectable> IIterable<Object^>
IEnumerable IBindableIterable IBindableIterable

如果ItemsSource屬性值也實作隨機存取清單介面,ItemsControl可以提供更佳的效能。

.NET C++/WinRT C++/CX
IList < 物件> IVector<IInspectable> IVector<Object^>
IReadOnlyCollection < 物件> IVectorView<IInspectable> IVectorView<Object^>
IList IBindableVector IBindableVector
IBindableVectorView IBindableVectorView
IBindableObservableVector IBindableObservableVector

如果ItemsSource屬性值也實作集合變更的通知介面,ItemsControl可以引發集合變更的通知事件。

.NET C++/WinRT C++/CX
INotifyCollectionChanged INotifyCollectionChanged INotifyCollectionChanged
ObservableCollection < 物件> IObservableVector<IInspectable> IObservableVector<Object^>

針對 .NET,若要處理集合變更的事件, ItemsSource 屬性也必須實作非泛型 IList 介面。

適用於