Before you begin
This is a Xamarin.Forms class which includes projects for iOS, Android, and Windows. When working on the exercises, you can select the easiest supported platform to run your application on. Refer to the Setup Requirements on the Xamarin University website if you need help with your development environment.
Overview
This session shows how to use the ListView
control in Xamarin.Forms to display collections of data. You will learn how to interact with the data and customize the way the information is displayed.
Objectives
- Display a collection with ListView
- Add and remove items dynamically
- Customize ListView rows
Lecture
XAM280 - Using ListView in Xamarin.Forms.
Exercises
Exercise materials are available from GitHub. The code can be cloned through a desktop Git client or downloaded directly as a ZIP file.
-
Display a list of items with a ListViewExercise
In this starting exercise, you will display a collection of data in aListView
using the default visualization. -
Select a rowExercise
Next, you will add the most common behavior used with theListView
: when the user taps an item, the app navigates to a details screen. -
Work with mutable listsExercise
This exercise continues our application by adding support to delete a row using aToolBarItem
placed in the navigation bar to show how to work with mutable lists. -
Add Pull to Refresh supportExercise
Next, in this group exercise, we will add a "pull-to-refresh" gesture into the application. -
Use the built-in ImageCellExercise
In this final exercise, you will replace the text-based cell rendering with one of the built-in cell styles using aDataTemplate
. -
Homework: Add a context action to each rowExercise
In this homework exercise, you will add support to delete rows using a "swipe" gesture on the cell.