5

I'm using Prism 4.1 to write a composite application that uses a TabControl as a means of switching between the main modes of the application. I'm currently able to load views into the TabControl as separate tabs by simply navigating to the view with the TabControl region as the target:

In my Shell.xaml:

<Window>
  <Grid>
    <TabControl prism:RegionManager.RegionName="TabRegion" />
  </Grid>
</Window>

And in my Bootstrapper.cs, in the InitializeShell() method:

regionManager.Regions["TabRegion"].RequestNavigate("FirstTabView");
regionManager.Regions["TabRegion"].RequestNavigate("SecondTabView");
regionManager.Regions["TabRegion"].RequestNavigate("ThirdTabView");

However, the views and (more importantly) their respective ViewModels are instantiated immediately when the application starts, rather than when a view's tab is selected. Is there a way to configure Prism to only load a view when its tab has been activated?

I've tried defining the views in separate modules, and loading the modules with the InitializationMode.OnDemand parameter, but this doesn't seem to have any effect; I'm assuming this is because the RequestNavigate method is enough to activate the module.

Any ideas would be much appreciated!

Nathan Friend
  • 12,155
  • 10
  • 75
  • 125
  • Looks like this was discussed previously [here](http://stackoverflow.com/questions/4756657/lazy-loading-in-tabcontrols-mvvm) – bland Oct 10 '13 at 17:30

0 Answers0