Collection Views
In the early phases of Xamarin.Forms, StackLayout
and ListView
were the two most popular options for displaying a collection of elements. The differentiating factor for these two views was the fact that StackLayout
was only used for static content (that is, no collection data binding) whereas ListView
was used to create a collection view where a collection of data items (that is, ItemsSource
) was displayed in the form of a template definition.
In fact, so far, we have used the ListView
element while creating our HomeView
, as well as the RootView
menu. If you look at how HomeView's uses of ListView
, you will immediately notice the main elements of the collection binding that allow the data binding in a ListView
:
<ListView ItemsSource="{Binding RecentProducts}"> <ListView.ItemTemplate> <DataTemplate> ...