Navigation within the external xap

Jul 3, 2010 at 1:25 PM
Edited Jul 3, 2010 at 1:38 PM

Hi Glenn,

I have problems with Navigation Framework in the scope of a single external xap loaded via Deployment catalog. All your MIX10 demos work fine but you deal with Pages loaded from external xap, no samples on using both the Frame and Page. It seems that there are some problems related to type resolution or something like that. We have chart modules with drill-down navigation support that rely on SL4 Navigation and there's no way easily replacing existing functionality with some sort of workarounds :(

You can easily reproduce this issue with your "MefNavifation" sample from MIX10 demo. Open "Orders" project and add a new page called "Order1". Now go to the "Orders.xaml" and put the following like somewhere inside "ContentStackPanel":

<navigation:Frame Source="/Orders;component/Order1.xaml"/>

Try launching solution and navigating to the "Orders" page. You will get an exception saying there are some problems finding the underlying type for "Order1.xaml". Sometimes I get problems even with addressing images within the page living inside separate package. I've tried all the alternatives like specifying frame source from code but nothing helps for the moment. The temporary solution for my project was adding a direct reference to the library instead of loading it via DeploymentCatalog and that helped resolving navigation issue (however this is not the desired design for the project).

Any ideas why it is happening with URIs and Navigation?

Thanks in advance,

Dennis

P.S. This thread also addresses this problem I think:

http://mef.codeplex.com/Thread/View.aspx?ThreadId=213127

 

Jul 12, 2010 at 11:10 PM

Hi,

I had a similar issue as I'm using a navigation scenario where I've got to navigate to controls loaded within a second XAP file. 

First, make sure your second XAP is loaded. 

  • I used a polling duplex service to poll a directory on the server and deploy XAP updates to the client.  
  • Careful, I've read polling duplex services arn't the most scalable solution in a production system.
  • Use a deployment dictionary client side to register the new parts with the container. 

Second, take a look at the INavigationContentLoader interface that you can use to intercept how URI mappings get resolved.  "MyCustomFrameContentLoader" below implements INavigationContentLoader.  This is a pretty sweet SL addition.  I can't remember if this was in SL3 or not, but it is in SL4.

            <navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}" 
                        Source="" 
                        JournalOwnership="Automatic" >
                <navigation:Frame.ContentLoader>
                    <myCustomNamespace:MyCustomFrameContentLoader/>
                </navigation:Frame.ContentLoader>
                <navigation:Frame.UriMapper>
                    <uriMapper:UriMapper>
                        <uriMapper:UriMapping Uri="" MappedUri="/MyAssemblyName.MyControlName, MyAssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
                        <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/{pageName}"/>
                    </uriMapper:UriMapper>
                </navigation:Frame.UriMapper>
            </navigation:Frame>
There was an example about how to do this online, but I can't seem to find it ATM.  Hope this helps a bit.
Jul 12, 2010 at 11:14 PM

Ah found it.  http://www.davidpoll.com/2009/12/07/opening-up-silverlight-4-navigation-event-based-and-error-handling-inavigationcontentloaders/

This explains a bit about one way you could implement the INavigationContentLoader.

-Nick

Jul 19, 2010 at 12:39 PM

Thanks a lot, that really helped me solving problems.