For a project I am recently working on, I needed a quick intro into the Silverlight 3 Navigation Framework and as ever so often I found myself checking out the tutorial videos on Silverlight.NET.
Tim Heuer’s Navigation Framework video is quite helpful and I would recommend it to anybody who needs a speedy introduction to the navigation framework introduced with Silverlight 3. The video shows the Navigation references and SDK controls needed, it talks about UriMapping and deeplinking plus some NavigationService and NavigationContext methods.
Instead of downloading the code right away, I decided to follow along and do the coding, while watching the video. But when I ran the app, an error message was awaiting me:

So I went through the most recent comments on the video’s page and discovered a very helpful blog entry from Mister GoodCat.
The video had been recorded in March 2009, when Silverlight 3 Beta was out. Clearly the Silverlight 3 RTM had some breaking changes in store for the navigation framework! To fix the problem I first tried out the first step outlined in Mister GoodCat’s article and added a preceeding “/”s to all URI’s throughout the app (Files: MainPage.xaml, CustomerList.xaml.cs). In fact; the error message gives you also a precise clue in that direction!
Running the app again, I could see that the error message had changed. This was error#2:

So I went on to try out the second fix; which was to add a UriMapper to the navigation:Frame declaration in MainPage.xaml. Here it is:
<navigation:Frame x:Name=”MainFrame” Source=”Home” HorizontalContentAlignment=”Stretch” VerticalContentAlignment=”Stretch” Margin=”20″ UriMapper=”{StaticResource uriMapper}”/>
This time the app just worked perfect!
Code Fix – Discovery:
I thought I should just make the code available here; as it’s almost identical to the code for the video except for the minor fix.
That’s when I decided to check out all the code differences line by line and made an interesting discovery! Once you add the UriMapper as a static resource; the preceeding “/” are no longer needed. I’m sure there is a very scientific explanation for that; which I haven’t had time to find out so far…
So – in brief; if you define the UriMapper as a static resource in the frame, your app should be good to go! You might not even come across this problem in newer tutorials; however this video is pretty good and the source fix is not that hard; right?
Source Download:
You can download the source code here.
The only difference is the app name; instead of NavigationSample, you will see SLNavigationSample. Probably page titles may also differ; but the code is identical in syntax. I started out with a clean Silverlight 3 + Web App and didn’t use the Silverlight Navigation Application option available in Visual Studio 2008.
Hopefully this tiny source fix will save you some time + trouble!






Thanks, CrocusGirl, for fixing Tim Heuer’s sources and saving me some time.
I wish we could navigate to the absolute URL of a xaml. The application I am creating has XAMLs created after the XAP by users, so content can be added dynamically without a programmer. The workaround is so tedious…
Thank you Crocus Girl.
The world is in a much better place when people like you are in it.
Thanks again.
Oh – that was unexpected; Thanks!