Silverlight Navigation Framework/Region Integration

Topics: Prism v4 - Silverlight 4
Aug 31, 2010 at 12:07 PM

Unfortunately the documentation chapter on Navigation is just a placeholder at the moment, but I'm looking for guidance on the best way to integrate PRISM modular application functionality with the Silverlight Navigation framework to best stupport browser navigation buttons, deep linking etc.

I believe the best approach would be to amend the Silverlight Navigation Framework shell "Frame" with the RegionManager attached property and to write a RegionAdapter for the Navigation:Frame class.  Is this the best way to proceed?  Although writing region adapters is fairly straightforwards I would have thought. given the importance of the Silverlight Navigation Framework, this region adapter should be delivered "Out of the box" the same way the three existing region adapters are delivered.

Is there a better way to integrate PRISM modularity with the navigation framework, or am I likely to hit any issues if I follow the RegionAdapter approach outlined above?

Aug 31, 2010 at 7:54 PM
Edited Aug 31, 2010 at 7:57 PM

I posted in the wrong thread.

Sorry for the inconveniences

Fernando Antivero
http://blogs.southworks.net/fantivero

Sep 10, 2010 at 3:23 PM
Edited Sep 10, 2010 at 3:23 PM

I’m also wondering if someone could give an opinion what is “the proper” way to implement a navigation functionality within prism

Regards, Boris

Sep 10, 2010 at 3:53 PM

We are actually working on this now.  The latest drop has a navigation quickstart that is region based, but we are doing work to ensure that the region based navigation can work with the built in Silverlight navigation.

Give us another few weeks and we should have the rough parts figured out and have some docs that should help.

Are there any specific scenarios you would really want to see around this?

 

 

Sep 16, 2010 at 1:50 AM

Hi, we are working on this at the moment too.

 We haven’t been able to find enough guidance on the navigation aspects so any information would be greatly appreciated! Here is a rough outline of our scenario and our current implementation:

We have the following view types

  1. PageView – navigable page view (e.g. can be accessed by typing a Uri and supports record navigation like /AccountModule/AccountDetails/SmithCo, where AccountModule is a friendly module/groupname, AccountDetails is the page view name, and SmithCo is the record identifier (usually an int))
  2. View – normal view as in prism, can be used in region, child window etc etc.
  3. PrintView – navigable, a view that is optimized for print output (usually we pair this with the PageView and uses the same ViewModel)
  4. ReportView – navigable, usually a “multipage view” which we append headers and footers to the print output.

At the present time we have implemented the following, but would like to replace with Prism bits if possible:

  1. Views are exported via a ViewExportAttribute which contains some custom metadata (group name, view name, view type, view model type, user roles)  e.g. 
[ExportView(LocalResources.AccountGroupName, LocalResources.AccountDetailsName, typeof(IAccoutDetailsVM), ViewType.PageView, UserRoles.Planner | UserRoles.ParaPlanner)]
  1. We’ve implemented a custom PageViewControllerService to track active PageViews and our IsDirty/IsBusy/HasErrors properties, The PageViewControllerService supports navigating away from a PageView and then returning (kinda MDI style) however, this isn’t the default option. The default is that on a navigation attempt the user is prompted to Save, Cancel, Discard if any (editable) views on the screen are dirty.
  2. We’ve implemented a custom content loader which handles the navigation using the standard navigation framework.
    1. It performs a check on the users’ roles to ensure they CanNavigate to the requested page
    2. Performs a check to see if the PageView exists – displays a custom error page if it doesn’t
    3. Invokes the service to prompt the user if the page is dirty, either cancels the navigation, instructs the current viewmodel to save (editable VMs implement ISaveable), or simply navigates (discarding changes)
    4. parses the Uri and looks up a view registry (with our custom metadata) then wires the ViewModel to the view (via a view factory)
    5. Returns the constructed PageView (or the in memory PageView)

There isn’t a great deal of code involved but there are a few aspects we are not happy with. We’ve used this solution as a temporary measure and we are actively looking for a permanent solution.

Not sure how common this scenario is but it’s something we’ve faced in a couple of projects now. We are big fans of Prism and any guidance/how-to’s would be fantasatic

Thanks!

Sep 20, 2010 at 2:16 PM

Hello,

I just want to mention that this topic is a very important for us in our project. We are using PRISM drop 6 and we really need to have the navigation framework nicely integrated. So we will wait for any improvement on this.

Thanks michaelpuleio, fantivero.

Sep 20, 2010 at 11:48 PM

Hi Again,

I’ve spent a few hours with Drop7 (+a few mins with Drop 8) and the Navigation framework its shaping up nicely! A couple of comments/questions

  1. How do we integrate/sync the browser’s nav and journal with Prism’s Navigation framework? (I may be missing something really obvious here
  2. At present it isn't possible to have 2 views with the same Name (but in different namespaces) (e.g. 2 modules with a ModuleSummaryView in each) at present when navigating the LocatorNavigationTargetHandler.GetTargetView (drop7) assesses candidates based on the Type.Name and selects FirstOrDefault(), which is understandable. Is it possible to have the framework navigate to say something like /ModuleName/ModuleSummaryView (or even just GetType().FullName)?

If the plan is to have these Uri’s exposed externally (i.e in the Browser's location bar) Perhaps have something along the lines of a UriMapper? Which should help with deeper navigation structures, for example /Level1/Level1.1/ViewName?query=2 etc (we also Localise our nav items where possible)

Thanks again for your efforts

Sep 22, 2010 at 2:38 PM

Hi,

Thanks for all your feedback. I will copy this as a work-item, so the team will be notified about all your feedback.

Please take into account that the last Monday a new drop (8) of Prism was released. You can find some of the navigation updates below:

  • Chapter 7 - Navigation documentation updated.
  • Navigation API in Regions updated
  • State-Based Navigation and View-Switching Navigation QuickStarts updated.

Fernando Antivero
http://blogs.southworks.net/fantivero

Sep 22, 2010 at 2:39 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Sep 22, 2010 at 5:54 PM

The current plan for Prism v4 is to not have full support for Silverlight integration "in the box".  We wanted to include this in v4, but in the time we have left for this release, we had to make some tough trade-offs and this did not make the cut line. 

We did do quite a bit of work to prove out that the current navigation system can be extended to work seamlessly (or as close to it as possible) with the Silverlight Navigation framework and Karl will be writing a number of blog posts describing how this to create an extension to Prism that will tie into Silverlight Navigation. This should give you a solid foundation to work from and cover the scenarios you mentioned.

I hope that helps even if it is not ideal.

Dec 17, 2010 at 9:36 AM

Could you please provide a link to the above blog you mentioned? I'm having a bit of trouble with the sl navigation and prism 4 region navigation. The Loaded event of the very first view that gets loaded in the region seems to get called once again when navigating away. This happens only on the first time. Thereon this behavior is not there and navigation seems to work fine. Its just the first time.