I have a Silverlight application where I periodically load more data and add it to the page as UserControls. I load about 25 objects in one set and create one UserControl for each object.
This ends up taking quite a bit of time! Loading 25 objects takes 50-150ms purely in the UI. This makes my animations rather jerky, which is very much undesirable.
Is there any way to speed up the loading of the UserControls? I would rather not add some sort of buffering layer which loads X items per second. I would also rather not preload some large buffer of UI objects, which I would zombiefy/reuse based on how much data comes in. At the moment, however, I can’t think of any other options.
The UserControls themselves are rather simple and I am very surprised that they load so slowly. Basically, I just create them (doing nothing expensive in the constructor), set the DataContext and add them to their parent canvas.
Is it supposed to be that slow? Is there something obvious I could be missing here? Can I somehow decouple this from the animations timing? I guess not – the UI is almost certainly single-threaded.
After a long time of trying various solutions on various projects, the only thing I can say is that it really is that slow. I have not found any other solution other than just plain creating as few objects as is humanly possible, all the time, everywhere.
UI object creation is amazingly slow. It seems to be a sad fact.