I have a TabControl
with several tabs. The first and main one is very simple one and takes virtually no time at all to load. The second one on the other hand is a representation of hundreds of complex objects, and takes about 1-3 seconds. The application fires up rapidly, but as soon as you click on the second tab, the application freezes for a short while, loading the Tab Control.
This is a quick illustration of the XAML code:
<Window x:Class="MyProgramme.MyMainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<TabControl VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0">
<TabItem Header="Simple View" >
<!-- Main view. Loads instantly. -->
<ContentPresenter x:Name="m_simple"/>
</TabItem>
<TabItem Header="Heavy View" >
<!-- Takes about 1-3 seconds to load-->
<ContentPresenter x:Name="m_heavy"/>
</TabItem>
</TabControl>
</Grid>
</Window>
Obviously, this waiting is not very user friendly, and I would like a way to explicitly load the second tab whenever it's convenient, which will be either at start-up, or whenever the UI thread is not too busy and can take the load. Is there a way of loading this tab without stalling the user's work flow?