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<物件> IVector<IInspectable> IIterable<IInspectable>
IEnumerable IBindableObservableVector IBindableIterable

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

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

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

.NET C++/WinRT C++/CX
受控桌面 C#/.NET Core 應用程式
System.Collections.Specialized.INotifyCollectionChanged

通用 Windows 平台 (UWP) 應用程式
Windows.UI.Xaml.Interop.INotifyCollectionChanged

IObservableVector<IInspectable> IObservableVector<IInspectable>

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

適用於