0

This is the scenario: To display lots of UIElements in a Panel.

Since the number of these controls might be large, I am worried about memory allocation and performance issues.

Visualization is an option, But I hope to be able to do better, because the goal is to just display the content of these controls and there is no need to handle Mouse or Keyboard events.

Is there any way to improve performance in this scenario?

Thanks.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Ramin
  • 2,133
  • 14
  • 22
  • How many is "lots"? Perhaps the memory/performance impact won't be as significant as you think. If it's a semi-reasonable number, it might just be simpler to quickly implement a basic test/GUI to see if it actually will be an issue. – Chris Sinclair Jul 04 '13 at 03:17

3 Answers3

0

You can just use a normal ListBox to display them, the default panel is the VirtualizingStackPanel which has IsVirtualizing property set to true by default.

VirtualizingStackPanel

Are you currently running into performance issues or preparing for them in case they happen? I would only worry about performance after you've generated and displayed all of your content and noticed problems.

Here is an article with some examples of how to manage large data sets and virtualization: http://www.codeproject.com/Articles/34405/WPF-Data-Virtualization

Kevin Nacios
  • 2,843
  • 19
  • 31
  • Thanks. I meant theoretically, when there is no need to handle mouse events or there is no need to properties like _IsMouseOver_ and ..., is there a way to improve performance? – Ramin Jul 04 '13 at 03:19
  • added a link to an article i found with some examples. also check out user1795804s link. I think that's probably the best to go off of for now – Kevin Nacios Jul 04 '13 at 03:23
0

You say Visualization... I'm assuming maybe you mean Virtualization? If so, then you may or may not know about this website: http://msdn.microsoft.com/en-us/library/cc716879.aspx

Besides Virtualization, they also talk about deferred scrolling. I hope this helps.

  • Thanks for correcting me. The users decide the number of the elements and I want to be ready for any scenarios. – Ramin Jul 04 '13 at 03:20
  • I really wouldn't worry about it. I'd enable Virtualization let .NET CLR take care of the rest. –  Jul 04 '13 at 03:39
0

I think these should help you:
1. Optimize Layout and Design
2. Optimize Text
All other useful links about performance can be found here: http://msdn.microsoft.com/en-us/library/aa970683.aspx but I think 2 above links will work well in your case.