Xamarin.Forms

Using ListViews

Introduction#

This documentation details how to use the different components of the Xamarin Forms ListView

Pull to Refresh in XAML and Code behind

To enable Pull to Refresh in a ListView in Xamarin, you first need to specify that it is PullToRefresh enabled and then specify the name of the command you want to invoke upon the ListView being pulled:

<ListView x:Name="itemListView" IsPullToRefreshEnabled="True" RefreshCommand="Refresh">

The same can be achieved in code behind:

itemListView.IsPullToRefreshEnabled = true;
itemListView.RefreshCommand = Refresh;

Then, you must specify what the Refresh Command does in your code behind:

public ICommand Refresh 
{
    get
    {
        itemListView.IsRefreshing = true; //This turns on the activity
                                          //Indicator for the ListView
        //Then add your code to execute when the ListView is pulled
        itemListView.IsRefreshing = false;
    }
}

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow