Hi
< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Some project, like the one that I’ve been working on the past 2 years, require large forms, combined from hundreds of controls, a single form can go 10 or 20 pages long.
We are currently using Microsoft InfoPath 2003 with the .NET framework, and although it is not that fast, rendering of a large from with a 1000 text boxes for example will take couple of seconds.
Of course our forms are much complex than just having text boxes, but I tried to build an Avalon application with a 1000 text boxes, and the performance was even worse than Windows Forms, a simple Web Form (HTML), or even InfoPath!.
I know the product is still beta, and my test are all on Windows XP, but I also know that the new rendering engine is built in over DirectX9, and it is expected to have an unprecedented performance boost, I just can’t see that in my tests yet.
I am not looking for animations or styles in a large form, I know that will be too much or a computer to handle (although it can be done), just a large form with standard controls.
I just can’t understand how the current controls are working with Avalon, take Microsoft Word for example, renders a 1000 pages of text and images instantly, what about Microsoft Excel, rendering tens of thousands of cells (text boxes) instantly, and calculates them too.
And both of Word and Excel, are 10+ years old products, built over GDI; why Avalon, the one build over the latest and greatest DirectX, is that slow when it renders a large form
Think about the computer games, Halo2 for example A large world, multiple plays, hundreds of characters, real time animation, millions of pixels and tons of complex calculations, and all rendered at real time on a simple Xbox.
What does it make a Windows Form more complex than that Just a simple cursor, a box with 4 lines, and some text inside, is it that hard

Why simple large forms are rendered that slow?
Michael Bird
My team has been doing a lot of perf work on Expression Interactive (formerly known as "Sparkle") which is an all-WPF application. At startup we have about 2000 elements on screen and this at time scales to 50000 or more. I can't emphasize enough how important it is to profile your application when you run into performance problems. We repeatedly find seemingly innocent code that is doing something very inefficient, most likely because it is just called too often...usually in Expression, sometimes in WPF. If you aren't already using it, Visual Studio 2005 has a new time based profiler, and just if useful is the CLRProfiler which measures your memory allocations: http://msdn.microsoft.com/library/ url=/library/en-us/dnpag/html/scalenethowto13.asp
As others have suggested, Virtualization sounds like a great strategy for your scenario. InfoPath, Word and Excel all use virtualization extensively to achieve their performance. In the particular case of TextBox we developed a performance optimization for our Property Browser where each row contains an editing area for the value. We created a little control (actually it is just a ContentControl with a Template) and added triggers to the Style. When not focused, the control contains a static TextBlock...when focused it changes its Template to contain an editable TextBox. Since the user can't edit more than one TextBox at a time anyway, there is no visible change...but WPF does not spin up as much editing machinery and things are faster.
If you look at my blog, I wrote a tiny little piece of code that walks your Visual Tree and counts (or displays) the contents. Sometimes, especially if you have any custom Templates, the WPF composition model will create more elements than you expect. This sort of analysis also led to big perf gains in Expression: http://blogs.msdn.com/johngossman/archive/2005/8/4.aspx
Finally, WPF has made huge performance improvements in just the past 3 months. I've had people who are running Expression on November CTP bits ask me how fast my computer was when they see it run on the latest bits...stay tuned.
Brian Welcker - MS
Why do you need so many controls on on single form Wouldn't be possible to break this form into multiple forms and do some sort of navigation between forms
Just out of curiosity, I have tried to put 1000 TextBoxes inside a ScrollViewer. The text boxes are generated dinamically and added to the window in the loaded event. On my computer it takes 6-7 seconds and it works very well.
Valentin Iliescu
NickReiser
Right now, I don't have access to a computer with Avalon so I can rewrite the previous sample using virtualization but you can check the numbers in the test: 5000 TextBlocks rendered in 46 ms vs 3210 ms.
Valentin
German Masis
Thank you for your feedback. I'm the program manager for WPF (Avalon) Performance, so, this data is both interesting and useful.
I would recommend that you review the WPF performance whitepaper that was referenced earlier in this thread. As an application author, this should give you some of the basic information you need to make your application performant. Also, as you alluded to, WPF is not yet released, so, we're still working on various tasks in preparation for release; this includes more performance work.
Ultimately, getting the performance you need out of your application will come from a combination of these. We're working on making the platform faster but application performance tuning will remain an important part of the app building process.
Thanks
KSC
So having hundreds of controls in a form is nothing, just code the controls correctly; it is no different than having millions of elements in a game rendered at real time.
George, that's a pretty naive statement.
Games just render what is seen on screen( more correctly what they can determine fast that could be seen, no point in spending more time finding what to draw than drawing a bit more ;) )
Applications as Word don't render the full document, just what is seen and a bit more for smooth scrolling, nor they have in memory the full document constructed.
You can investigate these area googling for topics like :
Flywight Design Pattern
Proxy Design Pattern
UI Virtualization
------- 3d rendering -----------
Binary Space Partitioning Trees ( BSP Trees )
Portal Culling
Everything is harder than what it seems..... always ;)
edwardbeck
Regardless, virtualization is your best bet. For example, I just created a simple application that has 1000 textboxes inside a ListBox (which exposes virtualization by default). The form doesnt take any longer to render than any other form. Turning off the ListBox's virtualization (VirtualizingStackPanel.IsVirtualizing="False") requires at least 6 seconds to render.
I wouldn't be surprised if Word and Excel implement some sort of virtualization method anyway.
heppiedad
Correct me if I am wrong, but a CPU running at 3 GHZ is will tick 3,000,000,000 times each second, in each tick, there are instructions executed (well, some of them will require more than a CPU tick).
< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
So having hundreds of controls in a form is nothing, just code the controls correctly; it is no different than having millions of elements in a game rendered at real time.
Anyway, “why do you need hundreds of controls on a form” is not different from “whey do you need to use Microsoft Word, can’t you simply have multiple notepad files and a set of images ”
I was working on a project that is porting a Lotus Notes application to Microsoft InfoPath, and I will be working next year on porting another Lotus Notes application to a Microsoft technology.
The lotus notes application (the one we are porting) is like a large Word Document, full with rich text, and standard controls, the end user already knows how to use the product, and requires the new product to look very similar to the existing one.
The idea is to have a large financial document that the end user is conformable with, and that large document split to very small items and stored in the database in a way the people who are mining the data are conformable with.
It is not hard to achieve, the problem is it is just too slow (in any environment built by Microsoft, including the new super fast Avalon).
7 seconds in your tests :-), imagine if an excel sheet with a 1000 cells took the same amount of time; people will simply dump the product and use something else.