This project has moved and is read-only. For the latest updates, please go here.

View Getting Instantiated Twice.

Jul 6, 2011 at 4:12 AM

Jeremy, Thanks in advance for your time. I created an app using the Jounce app template that you released recently. Compiling and running the default app generated an exception indicating some unitilized variable so I brought in the Jounce source to see if I could track it down. Well, it ran without the exception once I used the source project. But that's not the topic of this discussion I just thought I'd mention it. After I tested the default application I created a second view (User Control) and an associated ViewModel. I want the main window to simply embed the new user control as the Root View of the application which will dynamically load modules based on user interaction. The RootView is simply a Toolbar (as a ItemsControl) and an area for rendering the selected item. The problem that I have is that the RootView is being instantiated twice AND the ViewModel is never instantiated. I've placed breakpoints in the contructor for the views and the view models and can follow the instancing. I have placed a copy of the test project on my Skydrive( with the hope that you might be able to shed some light. Thanks again. Al

Jul 6, 2011 at 12:58 PM

You are just inserting the sub-view which doesn't give Jounce the ability to wire anything up because it is handed over to the Xaml parser.

What you would want to do is in the MainPage define a "MainRegion" using a content control. Route the ribbon view to the region and then raise a navigation event for the ribbon view in the Initialize method of the main view model. That will start the chain you are looking for. You can see examples and blog posts that demonstrate this.