I am working on an application that has some ListBox's of information, it is possible that these could hold quite a lot of information (maybe up to 6 or 700 complex items - multiple text fields and images).
I used the ListBox control in order to use the grouping, sorting and filtering functionality that you get with it, but it turns out that the filtering is very slow (and the responsiveness of the UI is important to the app).
So where I am now is instead of using either of the above methods, I am filtering by changing the visibility of the ListBoxItem's using something like this:
foreach (MyItemType item in myListBox.ItemsSource)
{
ListBoxItem lbi = (ListBoxItem)(myListBox.ItemContainerGenerator.ContainerFromItem(item));
if (item.Name.Contains("blah"))
{
lbi.Visibility = Visibility.Visible;
lbi.IsEnabled = true;
}
else
{
lbi.Visibility = Visibility.Collapsed;
lbi.IsEnabled = false;
}
}
This works very quickly even with over 500 items in the ListBox. I now have the problem that although the individual items i want hidden are now hidden, this leaves all of the group headers still visible and I can't see any method of hiding them from view.
Any help in hiding the groups (or even a better way of achieving the same thing) is much appreciated.
Thanks