Xamarin.Forms Guides | Samples

Xamarin.Forms.ListView Class

An ItemsView that displays a collection of data as a vertical list.

See Also: ListView


public class ListView : ItemsView<Cell>, IElementConfiguration<ListView>, IListViewController


The following example shows a basic use:

C# Example

using System;
using System.Collections.Generic;
using Xamarin.Forms;

namespace FormsGallery
class ListViewDemoPage : ContentPage
        class Person
            public Person(string name, DateTime birthday, Color favoriteColor)
                this.Name = name;
                this.Birthday = birthday;
                this.FavoriteColor = favoriteColor;

            public string Name { private set; get; }

            public DateTime Birthday { private set; get; }

            public Color FavoriteColor { private set; get; }

        public ListViewDemoPage()
            Label header = new Label
                Text = "ListView",
                FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
                HorizontalOptions = LayoutOptions.Center

            // Define some data.
            List<Person> people = new List<Person>
                new Person("Abigail", new DateTime(1975, 1, 15), Color.Aqua),
                new Person("Bob", new DateTime(1976, 2, 20), Color.Black),
                // ...etc.,...
                new Person("Yvonne", new DateTime(1987, 1, 10), Color.Purple),
                new Person("Zachary", new DateTime(1988, 2, 5), Color.Red)

            // Create the ListView.
            ListView listView = new ListView
                // Source of data items.
                ItemsSource = people,

                // Define template for displaying each item.
                // (Argument of DataTemplate constructor is called for 
                //      each item; it must return a Cell derivative.)
                ItemTemplate = new DataTemplate(() =>
                        // Create views with bindings for displaying each property.
                        Label nameLabel = new Label();
                        nameLabel.SetBinding(Label.TextProperty, "Name");

                        Label birthdayLabel = new Label();
                            new Binding("Birthday", BindingMode.OneWay, 
                                null, null, "Born {0:d}"));

                        BoxView boxView = new BoxView();
                        boxView.SetBinding(BoxView.ColorProperty, "FavoriteColor");

                        // Return an assembled ViewCell.
                        return new ViewCell
                            View = new StackLayout
                                Padding = new Thickness(0, 5),
                                Orientation = StackOrientation.Horizontal,
                                Children = 
                                    new StackLayout
                                        VerticalOptions = LayoutOptions.Center,
                                        Spacing = 0,
                                        Children = 

            // Accomodate iPhone status bar.
            this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            // Build the page.
            this.Content = new StackLayout
                Children = 

XAML for Xamarin.Forms supports the following properties for the ListView class:


true or false, to indicate whether the items in the list all have the same height.


true or false, to indicate whether grouping is enabled.


An integer that describes the height of the items in the list. This is ignored if HasUnevenRows is true.


Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions:,,,,,,,

The members of Xamarin.Forms.ListView are listed below.

See Also: Inherited members from Xamarin.Forms.ItemsView<Xamarin.Forms.Cell>

Public Constructors

Creates and initializes a new instance of the ListView class.
Creates and initializes a new instance of the ListView class, with the specified caching strategy.

Public Fields

static readonly
FooterPropertyBindableProperty. Backing store for the ListView.Footer property.
static readonly
FooterTemplatePropertyBindableProperty. Backing store for the ListView.FooterTemplate property.
static readonly
GroupDisplayBindingPropertyBindableProperty. Identifies the ListView.GroupDisplayBinding property.
static readonly
GroupHeaderTemplatePropertyBindableProperty. Identifies the ListView.GroupHeaderTemplate property.
static readonly
GroupShortNameBindingPropertyBindableProperty. Identifies the ListView.GroupShortNameBinding property.
static readonly
HasUnevenRowsPropertyBindableProperty. Identifies the ListView.HasUnevenRowsProperty property.
static readonly
HeaderPropertyBindableProperty. Backing store for the ListView.Header property.
static readonly
HeaderTemplatePropertyBindableProperty. Backing store for the ListView.HeaderTemplate property.
static readonly
IsGroupingEnabledPropertyBindableProperty. Identifies the ListView.IsGroupingEnabledProperty property.
static readonly
IsPullToRefreshEnabledPropertyBindableProperty. Backing store for the ListView.IsPullToRefreshEnabled property.
static readonly
IsRefreshingPropertyBindableProperty. Backing store for the ListView.IsRefreshing property.
static readonly
RefreshCommandPropertyBindableProperty. Backing store for the ListView.RefreshCommand property.
static readonly
RowHeightPropertyBindableProperty. The backing store for the ListView.RowHeightProperty property.
static readonly
SelectedItemPropertyBindableProperty. Identifies the ListView.SelectedItemProperty property.
static readonly
SeparatorColorPropertyBindableProperty. Backing store for the ListView.SeparatorColor property.
static readonly
SeparatorVisibilityPropertyBindableProperty. Backing store for the ListView.SeparatorVisibility property.

Public Properties

FooterObject. Gets or sets the string, binding, or view that will be displayed at the bottom of the list view.
FooterTemplateDataTemplate. Gets or sets a data template to use to format a data object for display at the bottom of the list view.
GroupDisplayBindingBindingBase. Gets or sets the binding to use for display the group header.
GroupHeaderTemplateDataTemplate. Gets or sets a DataTemplate for group headers.
GroupShortNameBindingBindingBase. Gets or sets a binding for the name to display in grouped jump lists.
HasUnevenRowsBoolean. Gets or sets a Boolean value that indicates whether this ListView element has uneven rows.
HeaderObject. Gets or sets the string, binding, or view that will be displayed at the top of the list view.
HeaderTemplateDataTemplate. Gets or sets a data template to use to format a data object for display at the top of the list view.
IsGroupingEnabledBoolean. Gets or sets whether or not grouping is enabled for ListView.
IsPullToRefreshEnabledBoolean. Gets or sets a value that tells whether the user can swipe down to cause the application to refresh.
IsRefreshingBoolean. Gets or sets a value that tells whether the list view is currently refreshing.
RefreshCommandICommand. Gets or sets the command that is run when the list view enters the refreshing state.
RowHeightInt32. Gets or sets a value that represents the height of a row.
SelectedItemObject. Gets or sets the currently selected item from the ListView.ItemsSource.
SeparatorColorColor. Gets or sets the color of the bar that separates list items.
SeparatorVisibilitySeparatorVisibility. Gets or sets a value that tells whether separators are visible between items.

Public Methods

Enters the refreshing state by setting the ListView.IsRefreshing property to true.
Exits the refreshing state by setting the ListView.IsRefreshing property to false.
On<T>() : IPlatformElementConfiguration<T, ListView>
Returns the platform-specific instance of this ListView, on which a platform-specific method may be called.
ScrollTo(Object, ScrollToPosition, Boolean)
Scrolls the ListView to the item.
ScrollTo(Object, Object, ScrollToPosition, Boolean)
Scrolls the ListView to the item in the group

Protected Methods

CreateDefault(Object) : Cell
Creates an instance of the default visual representation of an item.
Method that is called when the binding context changes.
OnSizeRequest(Double, Double) : SizeRequest
Method that is called when a size request is made..
SetupContent(Cell, Int32)
Application developers override this method to register event handlers for list view items.
Application developers override this method to unregister event handlers for list view items that they registered in ListView.SetupContent(Cell,int).

Public Events

ItemAppearingOccurs when the visual representation of an item is being added to the visual layout.
ItemDisappearingOccurs when the visual representation of an item is being removed from the visual layout.
ItemSelectedEvent that is raised when a new item is selected.
ItemTappedEvent that is raised when an item is tapped.
RefreshingEvent that is raised when the list view refreshes.

Explicitly Implemented Interface Members