Delpin Susai Raj Monday, 20 January 2020

Xamarin.Forms - Working with RefreshView

In this blog post, you will learn how to implement Pull to Refresh the Entire Page using RefreshView 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 most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

RefreshView (Pull to Refresh)

RefreshView is a container control that provides a pull to refresh functionality for scrollable content. Therefore, the child of a RefreshView must be a scrollable control, such as ScrollView, CollectionView, or ListView.

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

Start by creating a new Xamarin.Forms project. You wíll learn more by going through the steps yourself.

Create a new or existing Xamarin forms(.Net standard) Project. With Android and iOS Platform.

Use RefreshView

Make sure your Controls should be within ScrollView.

Setting up the User Interface

Here, Add RefreshView in your View. Make sure your content should be within ScrollView.

MainPage.Xaml

Add RefreshCommand 

Now, Add RefreshCommand for your RefreshView. This Command will perform while pull to refresh. After Refresh your data don't forget set IsRefreshing=false;

MainPageViewModel.cs

Click the "Play" button to try it out.

Change Refresh ActivityIndicator Color

Now, Change Refresh ActivityIndicator Color. Set RefreshColor="Color", Check bellow code.

MainPage.xaml

Click the "Play" button to try it out.

Wow, It's Working.😍

I hope you have understood how to use implement Pull to Refresh the Entire Page using RefreshView in Xamarin.Forms.

Thanks for reading. Please share your comments and feedback. Happy Coding 😀