0

I created a form with listview and ISingleOperation fo data refresh.

Then i created command in ViewModel.

 public IRelayCommand LoadInvoicesCommand
    {
        get
        {
            return GetCommand(() => Execution.ViewModelExecute(new LoadInvoicesOperation(_model), 10000));
        }
    }

ISingleOperation works well and returns

new Result() { ResultAction = ResultType.None };

Refresh operation is bound well

RefreshCommand="{Binding LoadInvoicesCommand}"

But refresh indicator "hangs" and not disapearing, what is wrong here?

pinedax
  • 9,246
  • 2
  • 23
  • 30
Horosho
  • 647
  • 1
  • 8
  • 22

1 Answers1

3

You need to bind a second property from the ListView named IsRefreshing to your ViewModel. This is a boolean property and is the one responsible to tell the ListView that the refreshing has started/completed.

An example of a ListView XAML

<ListView 
    VerticalOptions="FillAndExpand"
    IsPullToRefreshEnabled="true"
    RefreshCommand="{Binding LoadInvoicesCommand}"
    IsRefreshing="{Binding IsRefreshing, Mode=OneWay}"
    ItemsSource="{Binding YourItemSource}"
    ItemTemplate="{StaticResource ItemTemplate" />

Your ViewModel will need a public property called IsRefreshing and you will need to set this to false when you the refresh command has completed.

pinedax
  • 9,246
  • 2
  • 23
  • 30