This is my question: 1.I have 200,0000 Employee object(Id,Name,Job,Address) store at a database. 2.I read all Employee object to Empolyee[]. 3.I create a window form application (1) I create a WPF UserControl(inside ListBox),name is "wpfUserControl1". (2) I put "wpfUserControl1" into a window form. (3) I set wpfUserControl1.listBox.ItemsSource = Employee[]. (4) Employee objects was displayed immediately. //Performance is very good 4.I create a WPF Application (1) I create a MainWindow object. (2) I put a LitBox to mainWindow. (3) I set listBox.ItemsSource = Employee[]. (4) The speed of loading is very slow and occur outofmemeory exception. //If i load 1000 objects ,performance is too slow 5.My doubt is : Why same WPF UserControl was Hosted into WinFormApp and WpfApp ,it's performance difference is so big?
views:
27answers:
2Could it perhaps have something to do with virtualizing? For instance, the WPF datagrid has virtualizing turned on by default, but if you place the datagrid inside a stackpanel and don't provide any width/height restrictions, then you effectively nullify virtualization since the stackpanel allows the datagrid to grow infinitely thus having to create DataGridRows for hundreds of thousands items.
I'm just guessing that the same effect might be happening with your usercontrol. In WinForms the hosting control propbably provides specific width/height restrictions and doesn't allow the usercontrol to grow infinitely. In WPF on the other hand, depending on how your WpfApp's MainWindow is defined, the usercontrol might grow infinitely.
Try setting a specific width/height for your usercontrol or mainwindow and see if the performance gets better...
Thank for you answer.I seem to understand a little.I must to modify my test program to vertify it.If have any result will be post here.