diff --git a/Maui.DataGrid/DataGrid.xaml.cs b/Maui.DataGrid/DataGrid.xaml.cs index c11f48c..7325d01 100644 --- a/Maui.DataGrid/DataGrid.xaml.cs +++ b/Maui.DataGrid/DataGrid.xaml.cs @@ -1183,6 +1183,11 @@ private set _paginationStepper.Maximum = value; _paginationStepper.IsEnabled = value > 1; } + + if (PageNumber > value) + { + PageNumber = value; + } } } @@ -1274,43 +1279,6 @@ private void OnColumnsChanged(object? sender, NotifyCollectionChangedEventArgs e private void OnItemsSourceCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) { SortAndPaginate(); - - ICollection 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 GetInternalItems(int lookupCount = 1)