|
@@ -108,8 +108,11 @@ public partial class AvaloniaDataGrid : UserControl, INotifyPropertyChanged
|
|
|
private static void ItemsSource_Changed(AvaloniaDataGrid grid, AvaloniaPropertyChangedEventArgs args)
|
|
|
{
|
|
|
grid.Grid.ItemsSource = grid.ItemsSource;
|
|
|
- grid.Grid.CollectionView.CollectionChanged -= grid.CollectionView_CollectionChanged;
|
|
|
- grid.Grid.CollectionView.CollectionChanged += grid.CollectionView_CollectionChanged;
|
|
|
+ if (grid.Grid.CollectionView is not null)
|
|
|
+ {
|
|
|
+ grid.Grid.CollectionView.CollectionChanged -= grid.CollectionView_CollectionChanged;
|
|
|
+ grid.Grid.CollectionView.CollectionChanged += grid.CollectionView_CollectionChanged;
|
|
|
+ }
|
|
|
grid.UpdateSummaryRow();
|
|
|
}
|
|
|
|
|
@@ -170,6 +173,7 @@ public partial class AvaloniaDataGrid : UserControl, INotifyPropertyChanged
|
|
|
[RelayCommand]
|
|
|
private void Search()
|
|
|
{
|
|
|
+ if (Grid.CollectionView is null) return;
|
|
|
Grid.CollectionView.Filter = DoSearch;
|
|
|
Grid.CollectionView.Refresh();
|
|
|
UpdateSummaryRow();
|
|
@@ -178,10 +182,19 @@ public partial class AvaloniaDataGrid : UserControl, INotifyPropertyChanged
|
|
|
[RelayCommand]
|
|
|
private void Refresh()
|
|
|
{
|
|
|
+ if (Grid.CollectionView is null) return;
|
|
|
+
|
|
|
RefreshRequested?.Invoke(this, new());
|
|
|
Grid.CollectionView.Refresh();
|
|
|
}
|
|
|
|
|
|
+ private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
+ {
|
|
|
+ if (SelectionMode != SelectionMode.Multiple) return;
|
|
|
+
|
|
|
+ SelectionChanged?.Invoke(this, new AvaloniaDataGridSelectionChangedEventArgs(SelectedItems.ToArray()));
|
|
|
+ }
|
|
|
+
|
|
|
private void DataGrid_Tapped(object sender, TappedEventArgs e)
|
|
|
{
|
|
|
if (SelectionMode == SelectionMode.Multiple) return;
|