The issue
I've implemented a ListView
with a pull-to-refresh command following this approach by James Montemagno. Recently (I believe after updating to iOS10), the pull to refresh animation broke. Here's what happens:
- Pulling down: The spinner fills to 360 degrees. (Expected, correct behavior)
- Releasing: The spinner flashes and disappears. (Expected bahavior: spinner remains at top of listview and spins until
IsBusy
is set tofalse
) - Completing: The list item is added to the list. (Expected, correct behavior)
I've included an animated gif that shows exactly what happens.
Sometimes, I'm seeing this error popup in the application output:
Attempting to change the refresh control while it is not idle is strongly discouraged and probably won't work properly.
Any ideas on what could be the cause of this issue?
Version info
Xamarin.Forms version 2.3.2.127
iOS 10.0
Some more info on the code behind the gif:
I've followed the code in the post I've linked above quite strictly. To simulate a web request, I'm awaiting a Task.Delay
. I'm expecting the spinner to remain visible for 1000ms.
private async void ExecuteLoadNewStringCommand()
{
if (IsRefreshing)
return;
IsRefreshing = true;
LoadNewStringCommand.ChangeCanExecute();
await Task.Delay(1000);
ListItems.Add($"Another person ({ListItems.Count + 1})");
IsRefreshing = false;
LoadNewStringCommand.ChangeCanExecute();
}
My ListView
is bound to an ObservableCollection<string>
via xaml:
<ListView
ItemsSource="{Binding ListItems}"
HasUnevenRows="True"
IsPullToRefreshEnabled="True"
RefreshCommand="{Binding LoadNewStringCommand}"
IsRefreshing="{Binding IsBusy, Mode=OneWay}"/>
I can provide the Xamarin studio solution or any of the .cs/.xaml files if there's more you need to see.