0
votes

I'm currently writing a wpf-application that has a combobox. I get the values for the combobox from the DB (using a stored procedure), however, if I place them into the cbo, I have about 13,000+ values, which slow down the application.

What I would like is a cbo (user editable) that shows only 10 values and, while the user types, the list gets updated.

I am very new to wpf (as in a couple of days, maybe even a week), so please be clear about it.

thx!!!

Jan

2

2 Answers

0
votes

Please take a look at these posts that describes virtualisation with ComboBoxes:

WPF ComboBox performance problems by binding a large collections

Faster controls with UI virtualization

Hot Tip! Improving the Performance of a ComboBox

Try searching in google for many more examples.

0
votes

If you're that new, I am not sure how complex an answer you can understand yet, do you know DataBinding?

Anyhow, this is how I'd do it.

Declare an ObservableCollection of the type you're managing in the ViewModel of the ComboBox (This is an object that's set in the DataContext property of the ComboBox). When the user types the information, it will raise the TextChanged event, on the EventHandler for that event, fetch the information from the database using the partial string, then grab the result, and put it in the ObservableCollection.

For this to work, you need to go to your ComboBox and enable DataBinding on the ItemsSource property like so:

ItemsSource={Binding Mode=OneWay, Path=NameOfObservableCollectionProperty}