CollectionView is currently a preview, and lacks some of its planned functionality. In addition, the API may change as the implementation is completed.
CollectionView is a view for presenting lists of data using different layout specifications. It aims to provide a more flexible, and performant alternative to
ListView. While the
ListView APIs are similar, there are some notable differences:
CollectionViewhas a flexible layout model, which allows data to be presented vertically or horizontally, in a list or a grid.
CollectionViewhas no concept of cells. Instead, a data template is used to define the appearance of each item of data in the list.
CollectionViewautomatically utilizes the virtualization provided by the underlying native controls.
CollectionViewreduces the API surface of
ListView. Many properties and events from
ListVieware not present in
CollectionViewdoes not include built-in separators.
CollectionView is available in the Xamarin.Forms 4.0 pre-releases. However, it is currently experimental and can only be used by adding the following line of code to your
AppDelegate class on iOS, or to your
MainActivity class on Android, before calling
CollectionView is only available on iOS and Android.
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
By default, a
CollectionView will display its items in a vertical list. However, vertical and horizontal lists and grids can be specified.
CollectionView selection is disabled. However, single and multiple selection can be enabled.
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.
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.
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.