I've scoured the internet for what would most likely be a simple solution but none seemed to have had the same problem as me.
So to explain it briefly, I'm using Xamarin Forms and I have a ListView:
<ListView x:Name="kpiList"
Style="{StaticResource customList}"
HasUnevenRows="true"
SeparatorVisibility="None"
IsPullToRefreshEnabled="true"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="3">
</ListView>
I defined its RefreshCommand and IsRefreshing properties like this:
public partial class MainPage : ContentPage
{
bool _isRefreshing = false;
public bool IsRefreshing
{
get { return _isRefreshing; }
set
{
_isRefreshing = value;
OnPropertyChanged(nameof(IsRefreshing));
}
}
public ICommand RefreshData;
public MainPage()
{
RefreshData = new Command(RepopulateList);
kpiList.RefreshCommand = RefreshData;
kpiList.IsRefreshing = IsRefreshing;
{
void RepopulateList()
{
IsRefreshing = true;
Controller.KPIs.Clear();
foreach (KPIObj kpi in await
WebServices.GetUpdatedKPI(Controller.SavedKPIIds))
{
Controller.KPIs.Add(kpi);
}
IsRefreshing = false;
}
}
The strange thing is that the first time I pull to refresh it works perfectly fine. But the second time I try, it never enters the block of code that the Command is set to.
It is almost as if the ListView "loses" the pointer to the command after the first pull to refresh.