public void GetNextPage() { if (CurrentIndex >= AllProducts.Count) { return; } var diff = AllProducts.Count - CurrentIndex; if (diff > PageSize) { diff = PageSize; } CurrentProducts.Clear(); CurrentProducts = AllProducts.GetRange((int)CurrentIndex, (int)diff); CurrentIndex += diff; }
public void GetPreviousPage() { if (CurrentIndex <= 1) { return; } var diff = CurrentIndex - PageSize; if (diff < 0) { diff = CurrentIndex; } else { diff = PageSize; } CurrentProducts.Clear(); CurrentProducts = AllProducts.GetRange((int)(CurrentIndex - diff), (int)diff); CurrentIndex -= diff; }