Click here to Skip to main content
14,880,436 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi Friends,

While building an application, I found that my application is getting slower and slower while I put more and more data driven elements.
I mean if my listbox Itemsource is bound to 10 elements, it is working cool, but when it is 100, it is getting slow.

I have even made VirtualisationStackPanel.IsVirtualising on.

I dont know what the problem with the window.

Suggest me any UI related performance tuning, if possible.

Thanks.
Posted

WPF has some UI virtualization, such as you've mentioned with the IsVirtualising property. However, if your code loads up all the data in the background, that will still take more and more time if you load more and more data. You have to do the data loading virtualization yourself. It has nothing to do with the UI. That is assuming that by "getting slow" you mean "loading slow".
   
It seems like you are unconcerned with overloading the listbox and presentation of the data. Good programming design requires that you ask for only what is needed. Obviously, you are loading a considerable ammount of data that is unavailable to the user, but bloats up the processes of the listbox. You can only see a dozen or so items in the listbox control. The rest are just garbage data.

A better answer is to load only the current list to be shown and to blockstep loadings( 20 or less at a time ) until you select the ones that you are going to operate on. Then display the internal data of the selections as needed. The idea is to seperate presentation of data from the items that are displayed. Don't lump everything together and complain because your Piper Cub aircraft can't lift the Empire State Building. Apply balance to your designs. I've seen people try to load 8000 items into a list and wondered why it took so long to load and scroll. Another clue is found in Design Patterns. The user interface is not the place to store your data.

Happy programming.
   
First of all, does your machine have a good graphics card ? Second, does it have updated drivers ? Third, what are you showing in your elements, just text ? Is it possible that the issue is not the UI, but the code that creates and accesses the properties on the elements, or is it just a basic class with basic properties ?
   
No, My problem is not regarding this. Let me explain it further :

I have a listbox, which has placed buttons as Items. Each button has a stackpanel within it to show three TextBlocks.

Does this is where the problem is. If so, please let me know what would be the best way of doing this.

Well, The problem is not while loading data, it is actually a problem of WPF performance, means scrolling takes more time, simple events like mouse over animation takes longer time etc.

:((
   
If you are interested in WPF Performance, then you really need to read this[^] article. The WPF SDK provides a number of useful performance utilities. You can find out more about them here[^].

BTW - I find Snoop[^] to be invaluable when faced with seemingly intractable performance issues - with it I can see the Visual Tree and track into it to see what's actually been loaded. I also love Josh Smith's Crack.NET[^] for helping with things like this.
   
Comments
Abhishek Sur 19-May-10 5:13am
   
Thank you Pete.

I have already solved the issue using ObservableCollection. I was not aware of INotifyCollectionChanged that time. But I already did this and its working great.

Thanks anyway for your help.
Pete O'Hanlon 19-May-10 5:18am
   
You're welcome. This thread had popped to the top of the questions list, so I answered it without noticing that you'd posted it a while back. Still, it's useful info anyway.
[no name] 25-May-10 13:42pm
   
Reason for my vote of 1
The link to the article is temporarily unavailable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900