Share via


ItemsRepeater.ItemsSource Property

Definition

Gets or sets an object source used to generate the content of the ItemsRepeater.

public:
 property Platform::Object ^ ItemsSource { Platform::Object ^ get(); void set(Platform::Object ^ value); };
/// [get: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
/// [set: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
IInspectable ItemsSource();

void ItemsSource(IInspectable value);
/// [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
/// [get: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
/// [set: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
IInspectable ItemsSource();

void ItemsSource(IInspectable value);
public object ItemsSource { [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)] get; [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)] set; }
[Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
public object ItemsSource { [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)] get; [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)] set; }
var object = itemsRepeater.itemsSource;
itemsRepeater.itemsSource = object;
Public Property ItemsSource As Object

Property Value

Object

Platform::Object

IInspectable

The object that is used to generate the content of the ItemsRepeater. The default is null.

Attributes
Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallbackAttribute

Remarks

Use the ItemsSource property to specify the collection to use to generate the content of items. You can set the ItemsSource to any type that implements IEnumerable. Additional collection interfaces implemented by your data source determine what functionality is available to the ItemsRepeater to interact with your data.

This list shows available interfaces and when to consider using each one.

  • IEnumerable<T> (.NET) / IIterable<T>

    • Can be used for small, static data sets.

      At a minimum, the data source must implement the IEnumerable / IIterable interface. If this is all that's supported then the control will iterate through everything once to create a copy that it can use to access items via an index value.

  • IReadonlyList<T> (.NET) / IVectorView<T>

    • Can be used for static, read-only data sets.

      Enables the control to access items by index and avoids the redundant internal copy.

  • IList<T> (.NET) / IVector<T>

    • Can be used for static data sets.

      Enables the control to access items by index and avoids the redundant internal copy.

      Warning: Changes to the list/vector without implementing INotifyCollectionChanged won't be reflected in the UI.

  • INotifyCollectionChanged (.NET)

    • Recommended to support change notification.

      Enables the control to observe and react to changes in the data source and reflect those changes in the UI.

  • IObservableVector<T>

    • Supports change notification

      Like the INotifyCollectionChanged interface, this enables the control to observe and react to changes in the data source.

      Warning: The Windows.Foundation.IObservableVector<T> doesn't support a 'Move' action. This can cause the UI for an item to lose its visual state. For example, an item that is currently selected and/or has focus where the move is achieved by a 'Remove' followed by an 'Add' will lose focus and no longer be selected.

      The Platform.Collections.Vector<T> uses IObservableVector<T> and has this same limitation. If support for a 'Move' action is required then use the INotifyCollectionChanged interface. The .NET ObservableCollection<T> class uses INotifyCollectionChanged.

  • IKeyIndexMapping
    • When a unique identifier can be associated with each item. Recommended when using 'Reset' as the collection change action.

      Enables the control to very efficiently recover the existing UI after receiving a hard 'Reset' action as part of an INotifyCollectionChanged or IObservableVector event. After receiving a reset the control will use the provided unique ID to associate the current data with elements it had already created. Without the key to index mapping the control would have to assume it needs to start over from scratch in creating UI for the data.

The interfaces listed above, other than IKeyIndexMapping, provide the same behavior in ItemsRepeater as they do in ListView and GridView.

The following interfaces on an ItemsSource enable special functionality in the ListView and GridView controls, but currently have no effect on an ItemsRepeater:

Applies to