在WPF中将组合框与大量数据绑定 [英] Bind Combobox with huge data in WPF
问题描述
我正在尝试将组合框与自定义对象列表绑定.我的对象列表有大约15,000条记录,单击组合框后,组合框需要很长时间才能显示数据.
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.
下面是代码:
<ComboBox Height="23" Name="comboBox1" Width="120" DisplayMemberPath="EmpName" SelectedValue="EmpID" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling"/>
后面的代码:
List<EmployeeBE> allEmployee = new List<EmployeeBE>();
allEmployee = EmployeeBO.GetEmployeeAll();
comboBox1.ItemsSource = allEmployee;
allEmployee大约有1.5万条记录. 谁能建议我如何改善组合框性能?
allEmployee have around 15K record. Can any one Suggest how can I improve my combobox performance?
推荐答案
您可以按此处所述尝试VirtualizingStackPanel
-
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
正如其他人所说,您真的想重新定义您的UI,因为ComboBox不适合15,000条记录.
As others have said, you really want to re-imagine your UI, as a ComboBox isn't appropriate for 15k records.
这篇关于在WPF中将组合框与大量数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!