Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

virtualization of control

Hi

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++)
{                
 listBox1.Items.Add(i.ToString());
}

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.

Regards
Karan Gupta
0
KaranGupta
Asked:
KaranGupta
2 Solutions
 
databoksCommented:
How long is "long time" ?
0
 
KaranGuptaAuthor Commented:
3-4 seconds. The main concern is not time, but to see how virtualization helps in improving performance.
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
CodeCruiserCommented:
Its a WPF question and you did not choose that zone for it!
0
 
databoksCommented:
Well.. Have you tried to disable Virtualization and see how long time it takes?

0
 
KaranGuptaAuthor Commented:
CodeCruiser:

I tried to search it but could not find it.

databoks:

It is taking the same time that is why I have asked this query.
0
 
sybeCommented:
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.

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

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now