• Stars
    star
    222
  • Rank 178,283 (Top 4 %)
  • Language
    C#
  • Created over 8 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pull To Refresh a ScrollView or ListView in Xamarin.Forms

PullToRefreshLayout for Xamarin.Forms

Update - Officially Deprecated

This library is officially deprecated and you can now use the official RefreshView as part of Xamarin.Forms 4.3. No further work will be done on this library and all issues will be closed.


Implementation of pull to refresh layout for Xamarin.Forms targeting iOS and Android.

The goal was to create a cross-platform Xamarin.Forms Layout that could have it’s content set to anything and would enable pull to refresh capabilities.

A BIG thank you to Jason Smith for his assistance on some tricky logic.

For a detailed overview of the API and sample please read through my blog: http://motzcod.es/post/128274430137/pull-to-refresh-anyish-xamarinforms-view

Also available as a NuGet: https://www.nuget.org/packages/Refractored.XamForms.PullToRefresh/

Build Status: Build status

Important

If you are using the NuGet ensure that you call “PullToRefreshLayoutRenderer.Init();” in both your MainActivity and AppDelegate. (Similar to Xamarin.Forms.Maps).

Android: You must build and compile against SDK 8.1 or 9.0.

API

Simply create a PullToRefreshLayout like any other Layout and set the Content to a supported view.

var scrollView = new ScrollView
{
  VerticalOptions = LayoutOptions.FillAndExpand,
  HorizontalOptions = LayoutOptions.FillAndExpand,
  Content = /* Anything you want in your ScrollView */
};

var refreshView = new PullToRefreshLayout {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Content = scrollView,
                RefreshColor = Color.FromHex("#3498db")
            };

//Set Bindings
refreshView.SetBinding<TestViewModel> (PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay);
refreshView.SetBinding<TestViewModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand);

Content = refreshView;

Additionally, your content could be anything you want including a StackLayout:

Content = new StackLayout
{
  Children = 
  {
    new Label { Text = “Hello Pull to Refresh“ },
    refreshView
  }
};

You can of course do it in XAML:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage 
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    x:Class="RefreshSample.Views.ScrollViewXamlPage"
    xmlns:controls="clr-namespace:Refractored.XamForms.PullToRefresh;assembly=Refractored.XamForms.PullToRefresh"
    Title="Xaml Scroll">
   <controls:PullToRefreshLayout
          IsPullToRefreshEnabled="True"
          RefreshCommand="{Binding RefreshCommand}"
          IsRefreshing="{Binding IsBusy}"
          RefreshColor="Blue"> 
          <ScrollView
          HorizontalOptions="FillAndExpand"
          VerticalOptions="FillAndExpand">
            <StackLayout
                  HorizontalOptions="FillAndExpand"
                  VerticalOptions="FillAndExpand">
                <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue"/>
                <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Red"/>
                <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Yellow"/>
                <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Purple"/>
                <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Maroon"/>
                <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue"/>
                <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Red"/>
                <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Yellow"/>
                <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Purple"/>
                <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Maroon"/>
            </StackLayout>
          </ScrollView>
   </controls:PullToRefreshLayout>
</ContentPage>

Officially Supported Views:

  • ListView
  • ScrollView
  • CollectionView

Unofficial Supported Views

  • UICollectionView (iOS)
  • RecyclerView (Android)
  • GridView (Android)
  • Potentially all Android Views without a scroll, but it acts a bit odd on some
  • ^^You should probably use a ScrollView^^

License

The MIT License (MIT)

Copyright (c) 2015 Refractored LLC & James Montemagno

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

Xamarin.Plugins

Cross-platform Native API Access from Shared Code!
1,302
star
2

MediaPlugin

Take & Pick Photos and Video Plugin for Xamarin and Windows
C#
713
star
3

mvvm-helpers

Collection of MVVM helper classes for any application
C#
673
star
4

Hanselman.Forms

The most awesome Hanselman app
C#
671
star
5

InAppBillingPlugin

Cross-platform In App Billing Plugin for .NET
C#
630
star
6

monkey-cache

Easily cache any data structure for a specific amount of time in any .NET application.
C#
629
star
7

SettingsPlugin

Read and Write Settings Plugin for Xamarin and Windows
C#
325
star
8

GeolocatorPlugin

Geolocation plugin for Xamarin and Windows
C#
293
star
9

PermissionsPlugin

Check and Request Permissions Plugin for Xamarin and Windows
C#
282
star
10

ConnectivityPlugin

Connectivity Plugin for Xamarin and Windows
C#
262
star
11

ImageCirclePlugin

Circle Images for your Xamarin.Forms Applications
C#
240
star
12

StoreReviewPlugin

Request app store reviews across Xamarin and Windows applications
C#
183
star
13

MyCoffeeApp

Sample Xamarin.Forms app built live on in 101 series on YouTube
C#
153
star
14

MeetupManager

Meetup.com app to track users at events
C#
149
star
15

DeviceInfoPlugin

Device Information Plugin for Xamarin and Windows
C#
143
star
16

app-ac-islandtracker

Animal Crossing Island Tracking Mobile App
C#
135
star
17

Xamarin-Templates

Xamarin.Android Templates Pack
C#
130
star
18

xamarin.forms-toolkit

Toolkit for Xamarin.Forms (Controls, Behaviors, and Converters)
C#
128
star
19

Xam.NavDrawer

Navigation Drawer Sample + MvvmCross Sample for Xamarin.Android
C#
123
star
20

Xamarin.Forms-Awesome-Controls

Awesome controls to add to your Xamarin.Forms apps
C#
121
star
21

XamChat

SignalR Chat Xamarin App
C#
120
star
22

CurrentActivityPlugin

Always grab the current Activity of your Xamarin.Android app!
C#
115
star
23

Xamarin.Forms-Monkeys

Simple list of monkeys (master/detail) in a xamarin.forms application
C#
115
star
24

MyWeather.Forms

Xamarin.Forms Weather Demo using OpenWeatherMap
C#
110
star
25

app-monkeychat

Monkey Chat application feature Twilio IP Messaging
C#
109
star
26

MyStreamTimer

A cool app to count up or down that writes text to file for streamers
C#
99
star
27

FloatingActionButton-for-Xamarin.Android

FAB material design for Xamarin.Android
C#
91
star
28

PagerSlidingTabStrip-for-Xamarin.Android

Port of Pager Sliding Tab Strip for Xamarin.Android Material Design
C#
85
star
29

app-coffeecups

Coffee Consumption App built with Xamarin.Forms and Azure Mobile Apps
C#
82
star
30

vsts-mobile-tasks

VSTS Tasks for Mobile!
TypeScript
79
star
31

MonoDroidToolkit

A toolkit for Xamarin.Android providing a lot of awesome helpers
C#
71
star
32

TextToSpeechPlugin

Text to Speech Plugin for Xamarin and Windows
C#
62
star
33

MotzCodesLive

Sample Resources for Motz Codes Live on Twitch
C#
60
star
34

AndroidStreamingAudio

Sample of streaming audio in background service in Xamarin.Android
C#
57
star
35

MyExpenses

My Expenses Cross Platform Demo - VSToolBox
C#
54
star
36

app-pretty-weather

A very pretty weather application built with Xamarin :)
C#
54
star
37

app-essentials

Sample project highlighting Xamarin.Essentials
C#
53
star
38

AllExtensions-DI-IoC

C#
52
star
39

xamarin.forms-workshop

Xamarin.Forms Full Day Workshop
C#
49
star
40

LaunchMapsPlugin

Launch External Maps Plugin for Xamarin and Windows
C#
48
star
41

MauiApp-DI

C#
46
star
42

VibratePlugin

Vibrate Plugin for Windows and Xamarin
C#
45
star
43

TheXamarinShow

All source code from my show on Channel 9, The Xamarin Show!
C#
45
star
44

app-imagesearch-cogs

Image Search and Cognitive Service Xamarin app!
C#
45
star
45

MVVMSourceGenerators

C#
44
star
46

Coffee-Filter

Find Coffee Fast with this Xamarin.Android App
C#
43
star
47

VS2019-FirstXamarinApp

C#
40
star
48

app-myconference

Conference App Build with .NET MAUI
C#
40
star
49

BikeNow

Bike Now is the best way to enjoy Seattle's bike sharing system on Android
C#
39
star
50

MonkeysApp-Workshop

Xamarn.Forms Workshop sample monkey app for iOS, Android, and Windows
C#
39
star
51

Censored

A .NET Profanity Censoring Library
C#
38
star
52

work-from-home-setup

Equipment and Setup recommended for Work From Home
37
star
53

app-peloton

Peloton app clone built with Xamarin.Forms
C#
35
star
54

dotnet-conferences

A comprehensive community built list of .NET Conferences around the world!
34
star
55

app-compass

Creating a simple compass application with Xamarin.Forms and Xamarin.Essentials.
C#
32
star
56

CircleImageView-Xamarin.Android

A fast circle image for Xamarin.Android
C#
32
star
57

Xamarin.Forms-PullToRefreshListView

Implementation of pull to refresh for Xamarin.Forms ListView
C#
31
star
58

Mvx.Plugins.Settings

Settings plug-in for MvvmCross.
C#
30
star
59

app-SimpleSignalR

Xamarin app to listen to new items from SignalR and ASP.NET Core
C#
30
star
60

mycadence-arduino

With this DIY project and a simple $18 ESP32 Arduino board you will have a budget Cadence display for your indoor cycling bike for Peloton or Apple Fitness+
C++
29
star
61

PlanetXamarin

Planet Xamarin
C#
28
star
62

BatteryPlugin

Battery Plugin for Xamarin and Windows
C#
27
star
63

iBeaconsEverywhere

iBeacon example on iOS and Android
C#
26
star
64

app-monkeys

C#
25
star
65

LocalizationSample

C#
25
star
66

GifImageView-Xamarin.Android

Animated ImageView for your Xamarin.Android apps
C#
25
star
67

ContactsPlugin

Contacts Plugin For Xamarin and Windows
C#
24
star
68

plugin-template

Plugin for .NET Template
C#
23
star
69

xamarin-workshop

Xamarin workshops for building a Xamarin.Android and Xamarin.Forms App
C#
19
star
70

app-ocr-functions

Cognitive Services, Azure Functions, Azure Mobile Apps, and Xamarin
C#
19
star
71

MyStocks.Forms

Xamarin.Forms example of querying stock quotes and using text to speech apis.
C#
18
star
72

AirQualityApps

C#
18
star
73

Xamarin.Forms-Android-CustomProgressBar

Using a custom renderer to display and bind to my custom progress bar
C#
18
star
74

build2017-future-of-mobile

Live Player Demos from Future of Mobile at Build 2017
C#
18
star
75

XamDroid.StickyListHeaders

Xamarin.Android Port of StickyListHeaders
C#
17
star
76

FiveLetters

A clone of a clone of Wordle built with .NET MAUI
C#
17
star
77

BetterTogether

Blazor, ASP.NET Core, Xamarin, .NET Standard <3
C#
16
star
78

XamarinDNR

Dot Net Rocks, PCL, Azure!
C#
16
star
79

FrenchPressTimer

Cross Platform timer that counts down from 4 minutes
C#
16
star
80

forms-native-embedding

Xamarin.Forms Native Embedding Sample
C#
16
star
81

embeddinator-weather

C#
15
star
82

Covid19Stats

Desktop app to retrieve COVID-19 Stats and download them to files on disk for OBS/SLOBS with a timer :)
C#
14
star
83

PuppyKittyOverflow

PuppyKittyOverflow
C#
14
star
84

Jeffsum.NET

Jeff Goldblum text placeholder generator of pure amazingness. (Unofficial .NET version of Jeffsum.com by @seanehalpin)
C#
13
star
85

MyFirstOouiApp

C#
13
star
86

MarshmallowSamples

Get ready for Android 6.0 with these Marshmallow Samples
C#
13
star
87

Xamarin.Android-AppCompat

App compat for android
C#
13
star
88

ToolkitMessenger

Esample of .NET Toolkit Messenger
C#
13
star
89

build2021-intro-csharp-python

C# and Python are two of the most popular programming languages for developers in all areas of tech. From making web apps to doing machine learning, you can't go wrong with either of them! James and Christopher are here to introduce you to these two powerful languages, explore some “Hello, World” examples, and show you the docs, tools, and frameworks that can help students and beginners get started on coding today!
Jupyter Notebook
13
star
90

blog-samples

All code samples from http://motzcod.es and http://blog.xamarin.com
C#
12
star
91

jamesmontemagno

12
star
92

XamDroid.RobotoText

Roboto text everywhere!
C#
12
star
93

dotnet-maui-template

Default template idea for .NET MAUI
C#
12
star
94

app-tictactoe

A Xamarin.Forms Tic-Tac-Toe example
C#
12
star
95

embeddinator-hellosharedui

C#
11
star
96

OfficeLightControl

Workshop for building an office light switch app with IFTTT and Hues
C#
11
star
97

FormsAnimations

Sample application shown during the Xamarin.Forms webinar for animations.
C#
11
star
98

MonkeyFinder6000

C#
10
star
99

app-simplestocks

C#
10
star
100

MonoDroid.ActionBar

A port of https://github.com/johannilsson/android-actionbar
C#
10
star