Skip to content

Commit

Permalink
move delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Miller committed Dec 27, 2023
1 parent cffd687 commit 2381fab
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Maui.DataGrid/DataGrid.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ private void SortAndPaginate(SortData? sortData = null)
},
defaultValueCreator: _ => new ObservableCollection<DataGridColumn>());

/// <summary>
/// Gets or sets the ItemsSource for the DataGrid.
/// </summary>
public static readonly BindableProperty ItemsSourceProperty =
BindablePropertyExtensions.Create<DataGrid, IEnumerable>(
propertyChanged: (b, o, n) =>
Expand Down Expand Up @@ -418,16 +421,6 @@ private void SortAndPaginate(SortData? sortData = null)
}
});

private void OnItemsSourceCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
SortAndPaginate();

if (SelectedItem != null && InternalItems?.Contains(SelectedItem) != true)
{
SelectedItem = null;
}
}

/// <summary>
/// Gets or sets the ItemsSource for the DataGrid.
/// </summary>
Expand Down Expand Up @@ -1074,6 +1067,16 @@ private void OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
_itemSelectedEventManager.HandleEvent(this, e, nameof(ItemSelected));
}

private void OnItemsSourceCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
SortAndPaginate();

if (SelectedItem != null && InternalItems?.Contains(SelectedItem) != true)
{
SelectedItem = null;
}
}

private SortData? RegenerateSortedColumnIndex()
{
if (_sortedColumn != null && SortedColumnIndex != null)
Expand Down

0 comments on commit 2381fab

Please sign in to comment.