2

I have my own UserControl hundreds of which are displayed in a Grid. I have profiled my code and found the time is being taken by

MyUserControl.InitializeComponent(), 

i.e. creating each one of my MyUserControl's.

UI Virtualization would be the perfect solution, i.e. not creating the control until it is visible, because most of the controls are off screen. However these controls do not live in an ItemsControl so is there anyway to do this in WPF?

7
  • 2
    Can you make them "live in a itemscontrol"? How does your Grid look alike? If you can make them "live in a itemscontrol" as example in a listbox then just set the virtualization flag to true. Jul 31, 2013 at 6:01
  • Another possiblity would be to only add the currently visible UserControls. This may be hard, but you could fill in dummy controls and check which are visible with the answer here stackoverflow.com/questions/1517743/…
    – Daniel
    Jul 31, 2013 at 6:07
  • 2
    @Daniel do not try to reinvent virtualization. This does not make sense. Jul 31, 2013 at 6:59
  • I guess thats true, however, it does depend on the circumstances...
    – Daniel
    Jul 31, 2013 at 7:41
  • @ReneNiediek is there anyway to use WPF's existing virtualization in my case?
    – markmnl
    Jul 31, 2013 at 7:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.