3

I am trying to bind combobox with custom object list. My object list have around 15K record and combobox takes long time to show the data after clicking on combobox.

Below are the code:

<ComboBox Height="23" Name="comboBox1" Width="120" DisplayMemberPath="EmpName" SelectedValue="EmpID" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling"/>

code behind:

List<EmployeeBE> allEmployee = new List<EmployeeBE>();
allEmployee = EmployeeBO.GetEmployeeAll();
 comboBox1.ItemsSource = allEmployee;

allEmployee have around 15K record. Can any one Suggest how can I improve my combobox performance?

Community
  • 1
  • 1
sanjay jadam
  • 221
  • 1
  • 3
  • 8

3 Answers3

5

That's bad UI design: No user will read through 15K records.

You can improve the performance by allowing the user to enter some filter criteria before showing the results, for example, by using an AutoCompleteBox instead of a ComboBox.

Community
  • 1
  • 1
Heinzi
  • 167,459
  • 57
  • 363
  • 519
  • Agreed, `AutoCompleteBox` or even an appropriate `ListBox` with text search enabled is definitely the solution – Damascus Jul 07 '11 at 12:50
4

You could try a VirtualizingStackPanel as described here - http://vbcity.com/blogs/xtab/archive/2009/12/15/wpf-using-a-virtualizingstackpanel-to-improve-combobox-performance.aspx

As others have said, you really want to re-imagine your UI, as a ComboBox isn't appropriate for 15k records.

devdigital
  • 34,151
  • 9
  • 98
  • 120
0

Try using a VirtualizingStackPanel as ItemsPanel for the ComboBox.

<ItemsPanelTemplate x:Key="ComboBoxItemsPanelTemplate"> 
   <VirtualizingStackPanel/> 
</ItemsPanelTemplate>

<ComboBox ItemsPanel="{StaticResource ItemsTemplate}"/>
Yiğit Yener
  • 5,796
  • 1
  • 23
  • 26