ExportViewToRegion timing

Feb 1, 2013 at 7:29 PM
I have a main view with two regions. One has a ribbon interface, the other contains the currently selected view (a form), based on a selection in the ribbon. There are six views that are exported to the "MainFormsRegion" using attributes, e.g.:
[ExportAsView(typeof(Administration))]
[ExportViewToRegion(typeof(Administration), Global.Constants.MAIN_FORM_REGION)]
public partial class Administration : UserControl
{
    public Administration()
    {
        InitializeComponent();
    }
}
All of the views are initialized when the app starts up, but I'd like to defer initialization of all but one view. Is that possible?

Thanks,
-Jay
Coordinator
Feb 8, 2013 at 12:34 PM
I probably need a little more context. Does that region have an adapter that supports multiple children? And what part of initialization are you concerned about, the initialization of the view itself or the initialization of the view model? You should be able to defer any functionality in the view until it is visible by moving that into the Loaded event. For the view model, the activate method shouldn't be called until you raise a navigation event for it.
Feb 9, 2013 at 1:43 AM
I'm concerned with both the view and the viewmodel. Both of them are being instantiated for each view that is exported to the main form region when the program starts up. Ideally, one or two of them should be spun up initially, and then the others only when actually activated via navigation. I did not implement a region adapter. Maybe that would add some control over the process?
Feb 11, 2013 at 10:37 AM
Why not put the other pages in a separate xap, and load it in dynamically when the user navigates to one of them?