Skip to content

Commit

Permalink
Merge pull request #160 from symbiogenesis/fix-pagination-bug
Browse files Browse the repository at this point in the history
fix pagination bug
  • Loading branch information
symbiogenesis authored Feb 14, 2024
2 parents 3538d4d + d4fc616 commit 3a23b66
Showing 1 changed file with 5 additions and 37 deletions.
42 changes: 5 additions & 37 deletions Maui.DataGrid/DataGrid.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,11 @@ private set
_paginationStepper.Maximum = value;
_paginationStepper.IsEnabled = value > 1;
}

if (PageNumber > value)
{
PageNumber = value;
}
}
}

Expand Down Expand Up @@ -1274,43 +1279,6 @@ private void OnColumnsChanged(object? sender, NotifyCollectionChangedEventArgs e
private void OnItemsSourceCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
SortAndPaginate();

ICollection<object> internalItems;

switch (SelectionMode)
{
case SelectionMode.Single:
if (SelectedItem == null)
{
break;
}

internalItems = GetInternalItems(SelectedItems.Count);

if (!internalItems.Contains(SelectedItem))
{
SelectedItem = null;
}

break;
case SelectionMode.Multiple:
if (SelectedItems == null)
{
break;
}

internalItems = GetInternalItems(SelectedItems.Count);

foreach (var selectedItem in SelectedItems)
{
if (!internalItems.Contains(selectedItem))
{
SelectedItems.Clear();
}
}

break;
}
}

private ICollection<object> GetInternalItems(int lookupCount = 1)
Expand Down

0 comments on commit 3a23b66

Please sign in to comment.