title: Silverlight NavigationService Is Always Null
body: <p>I read that a few people were having a problem with this so I wanted to post a (somewhat) elegant solution I came up with while trying to deal with this. The problem is when you create templated pages in Silverlight and the ContentControls do not have the parent Frame's NavigationService (it's always null when you try and use it). There are similar scenarios where a NavigationService is present in intellisence but is always null. To enable site-wide Navigation:</p>
  
  <ol>
  <li><p>Create a new <code>UserControl</code> (I called mine 'NavFrame') that has a Navigation Frame in it (I called mine 'RootFrame').</p></li>
  <li><p>Inside this Frame you can set whatever content you like.</p></li>
  <li><p>Set this UserControl as your <code>RootVisual</code> in App.xaml.cs (i.e. <code>this.RootVisual = new NavFrame();</code>).</p></li>
  <li><p>To use the NavigationService in any of your pages you can type something like:</p>
  
  <pre><code>((NavFrame)App.Current.RootVisual).RootFrame.NavigationService
      .Navigate(new Uri("Your Uri", UriKind.RelativeOrAbsolute));
  </code></pre></li>
  </ol>