Question

I've have a data source (of type List) with about 30'000 entries.

public class LocationItem
{
    public string Name { get; set; };
    public double Latitude { get; set; };
    public double Longitude { get; set; };
    public double Height { get; set; };
}

After binding this source to my AutoCompleteBox each entered letter needs about 1-3s to filter. Filter type is 'Custom'. My filter method isn't the bottleneck - I checked that with the 'Stopwatch' class and with a performance profiler. Filterings starts not before the fourth character.

The only alternative to be a little faster is using the TextChanged event instead of the implementeted filter behavior. In the TextChanged event I filter the original data source (Linq) and bind only the filtered subset to the AutoCompleteBox.

Ist there any onther way to go, to enhance the performance? Or whats best practice to bind a data source (with thousands of entries) to the AutoCompleteBox with filter functionality?

Kind regards, Danny

Was it helpful?

Solution

It would be better if you perform asynchronous filtering.
Here is a tutorial http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx for using AutoCompleteBox in Silveright. There is an example of asynchronus filtering. The example is with web service but you can replace it with local service, that loads your data from file or collection, you have already loaded.

OTHER TIPS

void SetData()
{
    ...
    autoCompleteBox = Data.GetRange(0, 30);
    ...
}

void autoCompleteBox_DropDownOpened(object sender, RoutedPropertyChangedEventArgs<bool> e)
{
    autoCompleteBox.ItemsSource = Data;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top