Search code examples
wpfperformancecomboboxlarge-data

Bind Combobox with huge data in WPF


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?


Solution

  • 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.