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

  1. Display a collection with ListView
  2. Add and remove items dynamically
  3. 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.

  1. Display a list of items with a ListView
    Exercise
    In this starting exercise, you will display a collection of data in a ListView using the default visualization.
  2. Select a row
    Exercise
    Next, you will add the most common behavior used with the ListView: when the user taps an item, the app navigates to a details screen.
  3. Work with mutable lists
    Exercise
    This exercise continues our application by adding support to delete a row using a ToolBarItem placed in the navigation bar to show how to work with mutable lists.
  4. Add Pull to Refresh support
    Exercise
    Next, in this group exercise, we will add a "pull-to-refresh" gesture into the application.
  5. Use the built-in ImageCell
    Exercise
    In this final exercise, you will replace the text-based cell rendering with one of the built-in cell styles using a DataTemplate.
  6. Homework: Add a context action to each row
    Exercise
    In this homework exercise, you will add support to delete rows using a "swipe" gesture on the cell.

Additional resources

Working with ListView Data Binding Basics - Bindings and Collections