Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

IncrementalLoadingPage CollectionView

$
0
0

hi

Causes **synchronous **interference
And it makes the data load a lot

**void **method Works without problems

public class CategorieListViewModel : INotifyPropertyChanged
{
public ObservableCollection ListItems { get; set; }

    public ICommand LoadMoreDataCommand => new Command(GetNextPageOfData);

    public CategorieListViewModel(string NameEnSlug)
    {
        this.NameEnSlug = NameEnSlug;
        ListItems = new ObservableCollection<GetListProductByCategorieModel>();
    }

    private string NameEnSlug { get; set; }
    private int PageIndex { get; set; } = 0;



    bool isRefreshing;
    public bool IsRefreshing
    {
        get { return isRefreshing; }
        set
        {
            isRefreshing = value;
            OnPropertyChanged();
        }
    }
    async void GetNextPageOfData()
    {
        IsRefreshing = true;
        Initialize();
        IsRefreshing = false;
    }

    async void Initialize()
    {          
        var ProductForCat = BLL.GetListProductForCategorie(NameEnSlug, PageIndex + 1);
        if (ProductForCat != null && ProductForCat.Result.ProductByCategorie.Count > 0)
        {
            PageIndex++;

            foreach (var item in ProductForCat.Result.ProductByCategorie)
                ListItems.Add(item);

            DependencyService.Get<Plugin.Toast>().Show("page" + PageIndex + " add " + ProductForCat.Result.ProductByCategorie.Count);
        }         
    }

    #region INotifyPropertyChanged

    public event PropertyChangedEventHandler PropertyChanged;

    void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }

    #endregion
}

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>