Delpin Susai Raj Wednesday 16 May 2018

Xamarin.Forms - ListView with Pull to Refresh

In this blog, you will learn how to use ListView with Pull to Refresh in Xamarin.Forms



Introduction

Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files are the most easily done tasks using native file APIs on each platform. Alternatively, embedded resources are also a simpler solution to distribute the data files with an app.

Pull to Refresh

Xamarin Forms ListView control has the ability to allow the user to pull down from the top of the ListView to trigger a refresh command. When the user triggers a PullToRefresh the Command will be invoked the Refreshed event.


Prerequisites
  • Visual Studio 2017(Windows or Mac)
Setting up a Xamarin.Forms Project

Start by creating a new Xamarin.Forms project. You’ll learn more by going through the steps yourself.
Choose the  Cross-platform App project under Visual C#-->Cross-platform in the New Project dialog.



Now Select the Blank App and Choose Portable Class Library(PCL).



Subsequently, go to the solution. In there, you get all the files and sources of your project (PCL). Now, select XAML page and double-click to open the MainPage.Xaml page.
You now have a basic Xamarin.Forms app. Click the Play button to try it out.



Setting up the User Interface

In this step create a simple ListView.



Now, write the following code.

MainPage.xaml

Now, add a list item to ListView. and write the following code.



MainPage.xaml.cs

Click the Play button to try it out.




Implement Pull to Refresh

In this step, you need to implement the Pull to Refresh in MainPage.Xaml.

IsPullToRefreshEnabled="True"




Now, write the following code.

MainPage.xaml


In this step add the RefreshCommand to ListView

Command RefreshCommand = new Command();




Now, write the code given below.

MainPage.xaml.cs

Full Code - MainPage.Xaml.cs



MainPage.Xaml.cs



Click the Play button to try it out.



I hope you have understood how to use ListView with Pull to Refresh in Xamarin.forms.

Thanks for reading. Please share comments and feedback.

4 comments:

  1. Thanks for sharing this informative content , Great work
    Leanpitch provides online training in ICP CAT during this lockdown period everyone can use it wisely.
    ICP-CAT certification

    ReplyDelete
  2. Thanks for sharing this informative content , Great work
    To crack Scrum master interview : Scrum master interview questions

    ReplyDelete
  3. Xamarin Monkeys: Xamarin.Forms - Listview With Pull To Refresh >>>>> Download Now

    >>>>> Download Full

    Xamarin Monkeys: Xamarin.Forms - Listview With Pull To Refresh >>>>> Download LINK

    >>>>> Download Now

    Xamarin Monkeys: Xamarin.Forms - Listview With Pull To Refresh >>>>> Download Full

    >>>>> Download LINK ua

    ReplyDelete
  4. Xamarin Monkeys: Xamarin.Forms - Listview With Pull To Refresh >>>>> Download Now

    >>>>> Download Full

    Xamarin Monkeys: Xamarin.Forms - Listview With Pull To Refresh >>>>> Download LINK

    >>>>> Download Now

    Xamarin Monkeys: Xamarin.Forms - Listview With Pull To Refresh >>>>> Download Full

    >>>>> Download LINK 3V

    ReplyDelete