private void OnLogMessagesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (logGridView == null || logGridView.ItemsSource == null || LogMessages == null) { return; } if (e.Action == NotifyCollectionChangedAction.Reset) { FilteredLogMessages.Clear(); } else { // Only apply filter if there's any new displayable messages bool refreshFilter = false; if (e.OldItems != null) { refreshFilter = e.OldItems.OfType <ILogMessage>().Any(IsMessageVisible); } if (!refreshFilter && e.NewItems != null) { refreshFilter = e.NewItems.OfType <ILogMessage>().Any(IsMessageVisible); } if (refreshFilter) { ApplyFilters(); } } }
private void ApplyFilters() { if (logGridView == null || logGridView.ItemsSource == null || LogMessages == null) { return; } FilteredLogMessages.Clear(); FilteredLogMessages.AddRange(LogMessages.Where(IsMessageVisible)); }