The best performance tweak for filtering, was toggling DataGridRow Visibility. It made magnitude of difference!
1.Add IsVisible property to the Collection Item that you Bind the DataGrid's ItemSource to.
private bool _isVisible = true;
public bool IsVisible
{
get { return _isVisible; }
set
{
if (_isVisible == value)
return;
_isVisible = value;
RaisePropertyChanged(()=>IsVisible);
}
}
2.Trigger the Visibility of DataGridRow by binding it to your IsVisible property:
<DataGrid.ItemContainerStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Visibility"
Value="{Binding Path=IsVisible,
Converter={StaticResource BoolToVisibility}}"/>
</Style>
</DataGrid.ItemContainerStyle>
3.Well, you gotta set the IsVisible somewhere I guess too, like in your ViewModel. Here's just a sample of what I am doing (just copy/paste job) - basically setting IsVisible to true or false based on some criteria in my other ViewModel:
FilterViewModel.OnFilter += (s, a) =>
{
foreach (Row row in ViewModel.Rows)
row.IsVisible = !FilterViewModel.FilteringItems.Any(item =>
item.IsSelected && item.Name == row.Name);
};