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?

leppie
  • 115,091
  • 17
  • 196
  • 297
markmnl
  • 11,116
  • 8
  • 73
  • 109
  • 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. – ninja hedgehog Jul 31 '13 at 06: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 http://stackoverflow.com/questions/1517743/in-wpf-how-can-i-determine-whether-a-control-is-visible-to-the-user – Daniel Jul 31 '13 at 06:07
  • 2
    @Daniel do not try to reinvent virtualization. This does not make sense. – Rene Niediek Jul 31 '13 at 06:59
  • I guess thats true, however, it does depend on the circumstances... – Daniel Jul 31 '13 at 07:41
  • @ReneNiediek is there anyway to use WPF's existing virtualization in my case? – markmnl Jul 31 '13 at 07:53
  • @ninjahedgehog afraid no can do :| – markmnl Jul 31 '13 at 07:57
  • Give us more information about how does your Grid look alike – ninja hedgehog Jul 31 '13 at 08:23

0 Answers0