In a WPF application the main window has a content control to which one of user controls can be loaded. Each of these user controls has about a thousand small, simple custom controls. That’s why the rendering time for swithing over to another user control is uncomfortable.
My question is, what would be the correct way of somehow preloading views into the UI so as swithing over to another view be fast? Can it be done in a way, not visible for a user? Or rendering a XAML should always be done in a visible, focused part of a window, so making it impossible to preload something that could be needed in the future?
Please, note, that I don’t mean preloading data from a database.
I haven’t had need to do this so far, but:
You can try loading the content you want into a control which does not get displayed due to layout decisions. This should force the content to be created even though it will not be displayed immediately.
When you want to “bring the content in”, remove it from the visual tree from its current position (the exact method might depend on what its parent is exactly) and re-insert it as a child of another, visible, control.