31 July 2009 0 Comments

Silverlight 3 Navigation: Dynamically Loaded Pages… Now MEF Powered!

Recently David Poll posted a very cool technique for navigating to dynamically loaded pages and on demand downloading of pages in a Silverlight 3 application .  It was very cool but the explicit wire up of each page can be a pain in large applications.  So having just posted about MEF on Silverlight , I thought this was a great fit.  The Managed Extensibility Framework (MEF) is all about discovering and wiring up components and Silverlight 3 Navigation has some very interesting components.    But before I could get it done, our Test Manager, Dinesh Chandnani beat me to it.  He wrote this very cool example app that I extended just a bit. Download the all the source code and check out an live sample … The model is very simple.  You just create a page (via the Silverlight Page item template) and put metadata on them saying how to navigate to it.  The page can be in the same XAP or different XAP.  No need to wire them up.    For example, for a page in the same XAP, you just create a page and add some metadata to it 1: [PageMetadata(Content = "page1" , NavigateUri = "/page1" )] 2: public partial class Page1 : Page 3: { For a page in a different assembly, possibly delay loaded or conditionally loaded: 1: [PageMetadata(Content= "delayloaded" , 2: NavigateUri= "/DelayLoadedPages;component/DelayLoadedPage.dyn.xaml" )] 3: public partial class DelayLoadedPage : DynamicPage 4: { Pretty much the same, but we use the packURI syntax and David Poll’s Dynamic page classpattern (see his blog post above for more information)

Here is the original post:
Silverlight 3 Navigation: Dynamically Loaded Pages… Now MEF Powered!

If you liked this post, buy me a Coffee.

Leave a Reply