I have a WPF application where I show and hide lots of UserControl objects. The XAML code looks something like this:
<ItemsControl ItemsSource="{Binding Path=MyListOfStuff}" >
<Controls:MyControl Stuff="{Binding}"/>
</ItemsControl>
Creating those objects takes a lot of time. Profiling shows that 'InitializeComponent' takes a significant amount of time for the MyControl objects. I want to pre create these objects to reduce that time. How can I do that? I still need the xaml code and don't want to replace all of it with just code.
It's not possible to use virtualization because the items in the list are sometimes bigger than the view, so CanContentScroll must be False.