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!