Share via


Xamarin.Forms CollectionView

Introduction

The CollectionView is a flexible and performant view for presenting lists of data using different layout specifications.

Data

A CollectionView is populated with data by setting its ItemsSource property to any collection that implements IEnumerable. The appearance of each item in the list can be defined by setting the ItemTemplate property to a DataTemplate.

Layout

By default, a CollectionView will display its items in a vertical list. However, vertical and horizontal lists and grids can be specified.

Selection

By default, CollectionView selection is disabled. However, single and multiple selection can be enabled.

Empty views

In CollectionView, an empty view can be specified that provides feedback to the user when no data is available for display. The empty view can be a string, a view, or multiple views.

Scrolling

When a user swipes to initiate a scroll, the end position of the scroll can be controlled so that items are fully displayed. In addition, CollectionView defines two ScrollTo methods, that programmatically scroll items into view. One of the overloads scrolls the item at the specified index into view, while the other scrolls the specified item into view.

Grouping

CollectionView can display correctly grouped data by setting its IsGrouped property to true.