jamesmontemagno / Xamarin.Forms-PullToRefreshLayout

Pull To Refresh a ScrollView or ListView in Xamarin.Forms
218 stars 49 forks source link

Binding example doesn't work in Xamarin.Forms and iOS #43

Closed znelson32 closed 6 years ago

znelson32 commented 6 years ago

I don't get it. None of the breakpoints in the .cs are hit but the spinner image does appear. It just appears, spins, but nothing else happens.

AppDelegate contains PullToRefreshLayoutRenderer.Init();

XAML <pullToRefreshLayout:PullToRefreshLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" RefreshColor="Gray" IsPullToRefreshEnabled="True" RefreshCommand="{Binding RefreshCommand}" IsRefreshing="{Binding IsBusy}">

C# `private ICommand refreshCommand;

    private bool isRefreshing;
    public bool IsBusy
    {
        get { return isRefreshing; }
        set
        {
            if (isRefreshing == value)
                return;

            isRefreshing = value;
            OnPropertyChanged("IsBusy");
        }
    }

    public ICommand RefreshCommand
    {
        get { return refreshCommand ?? (refreshCommand = new Command(async () => await ExecuteRefreshCommand())); }
    }

    private async Task ExecuteRefreshCommand()
    {
        if (isRefreshing)
            return;

        IsBusy = true;
        ((List<object>)listView.ItemsSource).Clear();

        var data = new List<object>();

        data .Add(new { Name = "11111" });
        data .Add(new { Name = "22222" });
        data .Add(new { Name = "33333" });

        listView.ItemsSource = data;

        isRefreshing = false;
    }`
mericao commented 6 years ago

Same problem here.

znelson32 commented 6 years ago

I had really hoped I did something wrong but I guess there’s a bug. James can you help us out?

TGlev commented 6 years ago

Same here. @jamesmontemagno

jamesmontemagno commented 6 years ago

You need to set IsBusy = false;

Where did those code come from?