Initial View

Topics: Prism v4 - WPF 4
Feb 7, 2011 at 7:12 PM

I have created a shell application following the stock trader RI.  The major difference is all my views land in a single region "MainRegion".  The region is a content presenter because i only want one view active at time.  I load the views using the behavior included in the sample, the AutoPopulateExportedViewsBehavior.  For a while it was showing the Login screen first, like it should even though i didn't understand how.  Now i have added more views and can navigate between them, but the order in which the screens show is different.  It starts on the screen I added last and not the login screen.  Using the AutoPopulateExportedViewsBehavior whats the best way to force that to be the first view?

Feb 9, 2011 at 3:41 PM


Take into account that AutoPopulateExportedViewsBehavior is used to place views in regions defined by a host controls.

If your application has only one main region, then there is no need to use the aforementioned behavior. You could use the view injection approach to load your login view to the main region.

For example:

   public class ViewsModule: IModule
       IRegionManager _regionManager;
       public ViewsModule(IRegionManager regionManager)
           _regionManager = regionManager;           
       public void Initialize()
           IRegion mainRegion = _regionManager.Regions["MainRegion"];
           mainRegion.Add(new LoginView(_regionManager));

Then you could use the RequestNavigate method of the RegionManager in order to move forward into the other views, when the user login successfully.

You can read more about View Injection in Chapter 7: Composing the User Interface

I hope you find this information useful.


Miguel Bronzovic