This project has moved. For the latest updates, please go here.

Navigate to view in xap

Dec 10, 2010 at 10:23 AM

I have a Shell with a navigation menu.  Each menu item cause a ViewNavigationArgs event to be published.  Each of the views invoked from the shell is in a separate XAP.  Everything works.

I would like that when the shell loads a default view is shown.  In ShellViewModel.OnImportsSatsified I publish the appropriate ViewNavigationArgs event.  However, the Export of the ViewXapRoute has not happened yet and so the navigation does not occur and the Shell does not show the default view.  How do I publish the ViewNavigationArgs event after the Export of the appropriate ViewXapRoute has occurred?

I probably shouldn't ask two questions at the same time, but here goes.  Why is this fantastic, appropriately sized, understandable, friendly, instructive framework called 'Jounce'?  Jeremy's Opinionated Universal Newly Created Effort?  Jeremy's Only Universal Natural Computer Environment? Just One Universally Needed Creative Enterprise? Jeremy Only Used Nicely Crafted Examples?

Dec 12, 2010 at 12:09 AM

Hello Jeremy,

I am trying to use NavigationTrigger without success.  In my Navigation page xaml: < Services:NavigationTrigger Target = "{Binding AccountViewName}"  /> where AccountViewName is a string property in my NavigationViewModel which is set to the name of the view (AccountView).  I bind the view to the viewmodel using tags and exporting the ViewModelRoute property.  In the SimpleNavigationWithRegion QuickStart, you include a FallbackValue="Navigation" attribute.  What is the purpose of this attribute?  Is it required?

Thank you.

 

 

Coordinator
Dec 13, 2010 at 12:39 PM

@PaulLinton,

There are a few ways to do this. I typically have my shell with a view model, call it "ShellViewModel." For Activate to be called on the ShellViewModel, the views have to be loaded and that means all of the exports processed. So, if I have sub-views I want to activate, I'll raise their navigation events in the "Activate" method of the shell view model. In a future version I'll be working on fluent configuration of bindings as well (i.e. you can set them up at run time) so you'll have even more control.

Silverlight's "core" set of files are called Jolt. If you debug or profile you'll see the "JoltHelper." Jounce is a synonym for Jolt. "Jounce for Jolt." :-D

Coordinator
Dec 13, 2010 at 12:40 PM

@tbrmidev - can I see the entire block of XAML? I want to make sure the wrapped trigger piece is correct. It should work fine but I'd need to see the rest. Is it an issue of the trigger not being fired, or is there something happening inside the trigger (i.e. have you debugged into it?). The fall back is not required, it just as an example would fall back to a default page instead of failing the navigation - in my example the navigation is already rendered so that's like a "no-operation".

Dec 13, 2010 at 4:31 PM

Hello Jeremy,

I found the problem.  It was indirectly related to allowing the Imports to complete within the ShellViewModel.  Once I moved the relevant code to OnImportsSatisfied, the NavigationTrigger fired and loaded the appropriate view.  It would appear that I need to implement a more robust mechanism for coordinating view navigation from the shell view model.  I regularly encounter issues with timing, Publish, Activate, and OnImportsSatisfied.

Thank you for your assistance.

Dec 13, 2010 at 5:12 PM

Subview Navigation

Jeremy,  I have a question pertaining to "subviews".  My shell is comprised of two content controls (horizontal stack panel) one for navigation (on top) and one for the current view (main content region). The current view may have subviews. For example, one of the main views (Outlook View) is mapped to the main content region and contains a "sub-navigation system" which is left aligned (docked on the left). When a menu option is selected from the subsystem, the corresponding subview should appear to right of the "outlook menu" (below the navigation region). Hence the Outlook main view is not swapped out, only the subviews.

What approach would you recommend with respect to the shell and subview loading / navigation.

Thank you.

 

Coordinator
Dec 13, 2010 at 5:47 PM

Sure - this is a very common scenario! I would use the region management feature. Simply define the "right area" with a content control and tag is as "SubViewRegion." Export your subviews to the same region. You can use the navigation trigger and the event will automatically route the view into that region.