Effectively create multiple instances of winrt metro control

I want to be able to create several hundred instances of a winrt control (search result control) in a C # project. The problem is that it takes too much time (tenths of a second or worse) and must be executed in the user interface thread, creating kiosks and delays in showing the results.

I currently circumvented the issue by pre-caching many instances of the control at startup. This approach works, but affects startup time (profiling shows that 40% of the processor time near startup is done by caching these controls) and creates control details such as cache size.

I think the problem is that every time a control is created, redundant work, such as re-parsing XAML, is done by the underlying structure. Maybe there is a way to avoid repeating this work? Maybe I can cheaply clone existing control? Does anyone have any ideas?

+4
source share
2 answers

Forenote: Some time has passed, so Microsoft may already have installed win8 user interface virtualization. I did not check.

What I was doing at that time was just hacking my own user interface virtualization to get around this problem. Basically: caching controls and reusing them to display visible data (using a binary search tree to efficiently query what you can see). I wrote a blog post about this .

+1
source
  • You can pre-cache in parallel thread. Will have less impact on the startup time of multi-core processors

  • searchresult.memberwiseclone wil give you small copies. It may be faster, not sure

  • Could you use only one searchresult and fill it with the correct data before use? In this case, there is no need to create a lot. Just use it as a reusable container.

  • If time is used when adding controls to parent forms, you can use

    • suspendlayout / resumelayout (this is win32)
    • setting parent to invisible and back to visible when you're done
  • Is there any other way to do the same thing faster? (competing control, 3d party, etc.)

+1
source

All Articles