virtualization of control


I have created a listbox
<ListBox Margin="58,96,100,66"  Name="listBox1" VirtualizingStackPanel.IsVirtualizing="True" />

Open in new window

Now I am binding it from code behind
for (int i = 0; i < 1000000; i++)

Open in new window

Even I have set VirtualizingStackPanel.IsVirtualizing="True" even then why it takes a lot of time to load the list.

Please advice.

Karan Gupta
Who is Participating?
So you have a listbox with 1 million options in it.

What are you measuring?
The time to send those megabytes from server to client?
The time it takes the browser render such a listbox?

Because virtualization really makes no difference for those two.

If you want to measure the server-process only you will need to time it takes to generate the code. So compare begin (right before the loop) and end time (right after the loop) on the server.

How long is "long time" ?
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

KaranGuptaAuthor Commented:
3-4 seconds. The main concern is not time, but to see how virtualization helps in improving performance.
Its a WPF question and you did not choose that zone for it!
Well.. Have you tried to disable Virtualization and see how long time it takes?

KaranGuptaAuthor Commented:

I tried to search it but could not find it.


It is taking the same time that is why I have asked this query.
Anurag ThakurTechnical ManagerCommented:
my assumption is that you are doing manual data binding and not setting the data source and then call the bind method
My assumption is that when you set the data source and do data bind then the virtualization will kick in and will only load desired set of records and not all the records at a time
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.