How can I efficiently display lots of UIElements in a Panel? - c#

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.

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

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.

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.

Related

Kind of live debugging possible? (Especially UI manipulation)

I would like to know if there is a way to manipulate an App's UI live while running?
I am not a designer and I have many problems sometimes regarding matching colours etc.
The next problem is that anytime I would like to change e.g. the colour of a control I have to quit the App then go to VS2012, apply my changes, build and execute it again to see simple changes.
I know that I see any changes in the designer but I have to see the resulting screen to get an impression of the whole.
Is there a way to achieve this?
Add a secret keypress while Debug flag is set, that raises a form and allows you to select controls and expose a property sheet for them. Be a bit of work to get right, and a good stick of code even using reflection. Might be better off with a storyboard type app to do your designing.
Unlike styles in WPF which can be dynamically adjusted (which made this type of run-time adjustment simple), there isn't as elegant of a solution for Windows Store apps. Ideally, you'd have all of your UI and colors, etc. defined in XAML files and not settable through other means (as it becomes a longer term maintenance issue).
I'd suggest just adding enough test data and configuration so that you can see the look and feel of the pages (with colors, etc.) at design-time. Blend and Visual Studio are now quite good at showing a very reasonable near final rendering of the elements of the application. It's generally not too difficult to do anymore.
One thing I've done in the past was to make a single page/form that contained all of the styles and controls in a large scroll viewer. Then, we set it so it was configurable to the be the first thing to run. The tweak/build cycle was pretty fast, and the results were still very manageable.

Loading and unloading mechanism for items of a listbox in WPF

I want to create an application in WPF using C# in which I want to introduce Loading and unloading mechanism on items of a listbox in a certain visible area. In brief, there are a ton of items present in Listbox, while the user scrolling down or up inside a visible region then the visible items will be only take the memory or will be loaded and rest of the items whose are not visible they will not take any memory or will be unloaded.
I don't have any basic idea about how to go for it.Could anyone please let me know how to go for it, and what should be the basic steps I have to take and which articles should I have to look? Any clue would be highly appreciated.
Thanks in advance
you may look at VirtualMode this is one of the approaches to control the loading of items.
The comment above seems valid - if you try to do this as the user scrolls then it's going to create a very unstable UI. What about just adding a "more..." option at the bottom of the list if there's more data?

Increase Performance of DevEx WPF Grid

I'm using the DevEx DXGrid (WPF) to show about 2,000 rows of data. I'm using a DataRow Template to get Master-Detail behavior (a new detail grid for each row).
My application responds extremely slow to almost all use input (to the grid). for example:
scrolling
expand/collapse group rows
resize app window
I've contacted DevEx support about this - but they say the solution is non trivial and they are waiting until next major version to 'fix' this.
Have you found any solutions to these problems? I'm hoping there is a way to structure xaml or code to avoid some of the performance problems. I'd be very interested to hear what performance problems you've encountered with the DXGrid and how you solved (or not) them.
thanks.
Indeed, we have changed the way the DXGrid works and it should operate faster. However, this improvement will be only visible in 10.2 and it relates the expanding / collapsing group rows.
If you have problems with scrolling, please post a sample project in the support center showing your performance issues. We will try to improve the control based on your particular situation.
As a general rule of thumb, simply put: the less controls, the faster it will be.
When using the GridControl, you may want to look into using the CellDisplayTemplate and use a very lightweight control to display the content of the cell, and then use the CellEditTemplate for your heavier edit control, as the CellEditTemplate is not is not loaded until the user enters the cell. This becomes very powerful the bigger your GridControl is.
See 3 or 4 for more info on GridControl optimization.

WinForms Invoke/BeginInvoke

I have a C# win form where I read a file and show lines in a datagridview. Everything works fine.. and I use delegate and Invoke for displaying the lines as they are being read. It also shows a progressbar and does some other stuff like calculating line length and parse the lines to extract certain fields from each line.
Just curious, if anybody has tried this kind of implementation. Currently my app reads a 250MB file (having ~ 12000 lines) in little over 3 minutes (Win 7 32bit/celeron 2.66Ghz/4GB). I was wondering if it is possible to reduce the time - more of like by changing the way I implemented it.
Well, you're quite right to have second thoughts about this. What's probably the toughest read possible, War and Peace by Tolstoy, has roughly half a million words. What you're dumping to the screen is a hundred times more. It doesn't really matter how long it takes to put this much info on the screen, it will take your user a wholeheckofalot longer to even scroll through it.
I personally hesitate to ever put anything more than, oh, 50 items in a list. 100 tops. Beyond that, it becomes sheer torture for a human being.
To get there, allow your user to filter content, gradually drilling down in the huge result set to a relevant item. Exactly what that ought to look like is not clear from your question. Think about it for a bit, I'm sure you'll come up with something.
Ok...I love these questions. Why are you showing a user 250mbs of data in a data grid? There is NO WAY that an end user can process understand 250mbs of data in a grid. If the end user is pressuring you for this feature you need to address it with them from a "this is a bad idea" standpoint. Performance problems can usually be solved in most cases by educating the user. :-D
First, you need not load the entire file, nor display it. You can load portions of it for display. i.e. in the grid, you cannot show the enire file anyway, the screen is only so big. Consider loading only what you display (plus a few extra lines for smooth scrolling) and load the rest on demand as the user is scrolling through the content. The user will be unaware that the file is only partially loaded.
Even nicer would be if you have some logical grouping, in a book you could display the chapters, in a financial type application, either by account or time period.
Maybe something like VirtualMode can helps you:
Virtual mode is designed for use with very large stores of data. When the VirtualMode property is true, you create a DataGridView with a set number of rows and columns and then handle the CellValueNeeded event to populate the cells. Virtual mode requires implementation of an underlying data cache to handle the population, editing, and deletion of DataGridView cells based on actions of the user. For more information about implementing virtual mode, see How to: Implement Virtual Mode in the Windows Forms DataGridView Control.
P.S. About performance: no one except profiling tool can't helps you to solve any performance-related problems.

Silverlight Toolkit TreeView control and expandability

Is it possible to configure the TreeView control in the Silverlight tookit such that some or all of the hierarchy levels will be automatically expanded and ideally something that can't be collapsed at that level.
I'm using this control in large part due to the ease of handling hierarchical data and the ease with which I CAN expand/collapse levels. I'm being asked to do this selectively (i.e. only at the first level should I allow expand/collapse). I'm examining a Hierarchical Data Template to try and make this happen, but am having little luck and will certainly consider other options including a different control entirely if need be. My boss DOES want me to avoid having to purchase a control if at all possible.
Thanks in advance.
Cheers,
Steve
Just an FYI for the community. I was provided and answer to this question here. The upshot is that this can be accomplished with a combination of data templates and styles.

Categories