I'm running a Filter on ListView items. These items can belong to groups (have group ID). The user can tick a box so that all items pass the filter that pass through the (primary) filter OR belong to a group in which at least one item passes the filter.
My Filter method:
List<int> passedFilterGroupIDList = new List<int>();
private bool Filter(object obj)
{
if (AllItemsInGroupBoxTicked && (obj as X).GroupID != null)
{
foreach (int groupID in passedFilterGroupIDList)
{
if ((obj as X).GroupID == groupID)
{
return true;
}
}
bool passedPrimaryFilter = FilterA(obj) && FilterB(obj) && FilterC(obj);
if (passedPrimaryFilter)
{
passedFilterGroupIDList.Add((int)(obj as X).GroupID);
CollectionViewSource.GetDefaultView(listview.ItemsSource).Refresh();
// this begins to filter through all again (with updated passedFilterGroupIDList)
return true;
}
else
{
return false;
}
}
else
{
// ... not relevant to question
}
}
this works... exactly once - as I'm missing a way to reset the passedFilterGroupIDList after all Items have been filtered through.
And that's my question. Is there a way to run through another method (in which the list is reset) after all items' filtering has ceased?