I am trying to convert a standard Xamarin
Forms CollectionView inside a RefreshView on one page in my app. This has been
unexpectedly hard, and I don’t have a fully working page yet. I’m using MVVM
and the Command pattern and the content page is instantiated via the Xamarin
Shell, i.e. it has a header on top (not sure if this is significant).
The issues are in order of significance:
- I have not been able to get it
to work at all with iOS. On Android, it works, but on iOS, the refresh spinner
is not displayed, and the refresh command does not execute.
- Setting IsRefreshing in code
does not show the spinner, which is unfortunate as it can be used to indicate
to the user that the content is loading the first time the page is shown. This
is the behavior in the Xamarin Forms RefreshView that I’m migrating from.
- There are many values that you
have to tweak to get it working sort of like the standard RefreshView. Out of
the box, it is far too big and requires the user to drag it a long way before
the refresh is triggered. It has taken me hours of fiddling and it still does
not look like the standard refresh view. So, with the standard RefreshView,
this is the XAML:
RefreshView
IsRefreshing="{Binding IsRefreshing}"
Command="{Binding LoadItemsCommand}"
RefreshColor = “ForestGreen” >
…
While
with the SfPullToRefresh, it is as verbose as this:
pullToRefresh:SfPullToRefresh
ProgressStrokeColor="ForestGreen"
ProgressBackgroundColor="White"
PullingThreshold="75"
RefreshContentThreshold="0"
RefreshContentHeight="40"
RefreshContentWidth="40"
TransitionMode="SlideOnTop"
IsRefreshing="{Binding IsRefreshing}"
RefreshCommand="{Binding LoadItemsCommand1}" >
...
- It seems that you HAVE to set
IsRefreshing = true and then IsRefreshing = false for it to work at all. Again,
that is not how the standard RefreshView is working, where IsRefreshing is true
once the user has initiated the refresh and you then turn it off when you are
done. See also item 2) above.
- I usually declare my Commands
with a private setter, but if I do that, the app crashes with
MethodAccessException complaining that the setter is inaccessible.
While I appreciate that we typically have
more flexibility with your excellent controls and thus more properties and options
to set, I really would have liked the SfListView to have worked with the
standard RefreshView, or if that is impossible, then have the SfPullToRefresh
to work more like it out of the box.
P.S.
You should consider a better text editor here, maybe just switch to MD format like we are used to on github. That is far better for formatting code samples.