Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The .NET Multi-platform App UI (.NET MAUI) 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.
The following screenshot shows a CollectionView that uses a two-column vertical grid and allows multiple selections:
CollectionView should be used for presenting lists of data that require scrolling or selection. A bindable layout can be used when the data to be displayed doesn't require scrolling or selection. For more information, see BindableLayout.
While the CollectionView and ListView APIs are similar, there are some notable differences:
ItemsSource
is updated off the UI thread.ListView implementations can be migrated to CollectionView implementations with the help of the following table:
Concept | ListView API | CollectionView |
---|---|---|
Data | ItemsSource |
A CollectionView is populated with data by setting its ItemsSource property. For more information, see Populate a CollectionView with data. |
Item appearance | ItemTemplate |
The appearance of each item in a CollectionView can be defined by setting the ItemTemplate property to a DataTemplate. For more information, see Define item appearance. |
Cells | TextCell, ImageCell, ViewCell | CollectionView has no concept of cells, and therefore no concept of disclosure indicators. Instead, a data template is used to define the appearance of each item of data in the list. |
Row separators | SeparatorColor , SeparatorVisibility |
CollectionView does not include built-in separators. These can be provided, if desired, in the item template. |
Selection | SelectionMode , SelectedItem |
CollectionView supports single and multiple selection. For more information, see Configure CollectionView item selection. |
Row height | HasUnevenRows , RowHeight |
In a CollectionView, the row height of each item is determined by the ItemSizingStrategy property. For more information, see Item sizing. |
Caching | CachingStrategy |
CollectionView automatically uses the virtualization provided by the underlying native controls. |
Headers and footers | Header , HeaderElement , HeaderTemplate , Footer , FooterElement , FooterTemplate |
CollectionView can present a header and footer that scroll with the items in the list, via the Header , Footer , HeaderTemplate , and FooterTemplate properties. For more information, see Headers and footers. |
Grouping | GroupDisplayBinding , GroupHeaderTemplate , GroupShortNameBinding , IsGroupingEnabled |
CollectionView displays correctly grouped data by setting its IsGrouped property to true . Group headers and group footers can be customized by setting the GroupHeaderTemplate and GroupFooterTemplate properties to DataTemplate objects. For more information, see Display grouped data in a CollectionView. |
Pull to refresh | IsPullToRefreshEnabled , IsRefreshing , RefreshAllowed , RefreshCommand , RefreshControlColor , BeginRefresh() , EndRefresh() |
Pull to refresh functionality is supported by setting a CollectionView as the child of a RefreshView. For more information, see Pull to refresh. |
Context menu items | ContextActions |
Context menu items are supported by setting a SwipeView as the root view in the DataTemplate that defines the appearance of each item of data in the CollectionView. For more information, see Context menus. |
Scrolling | ScrollTo() |
CollectionView defines ScrollTo methods, which scroll items into view. For more information, see Control scrolling in a CollectionView. |
.NET MAUI feedback
.NET MAUI is an open source project. Select a link to provide feedback:
Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Customize layout in .NET MAUI XAML pages - Training
Create consistent user interfaces across different devices by using StackLayout and Grid.
Documentation
Specify CollectionView layout - .NET MAUI
By default, a CollectionView will display its items in a vertical list. However, vertical and horizontal lists and grids can be specified.
Define an EmptyView for a CollectionView - .NET MAUI
In .NET MAUI 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.
Configure CollectionView item selection - .NET MAUI
By default, CollectionView selection is disabled. However, single and multiple selection can be enabled.