Here's a simple example that I created to show how to make a ListBox control that has many items more manageable. As you type into the filter TextBox, the ListBox will only show the items that matches the filter. You can give the sample a try by clicking the XBAP link below.
http://blogs.vertigosoftware.com/Files/Alan/FilteredListBox/FilteredListBox.xbap
The magic happens in code by retrieving the default view for the ListBox's ItemsSource and applying a filter against it.
private void FilterTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
//Use collection view to filter the listbox
ObjectDataProvider peopleDS = (ObjectDataProvider)this.Resources["PeopleDS"];
ICollectionView collectionView = CollectionViewSource.GetDefaultView(peopleDS.ObjectInstance);
collectionView.Filter = new Predicate<object>(NameFilter);
}
public bool NameFilter(object item)
{
Person person = item as Person;
return (person.DisplayName.ToLower().Contains(FilterTextBox.Text.ToLower()));
}
Here is the full source code:
http://blogs.vertigosoftware.com/Files/Alan/src/filteredlistbox.zip