title: How do I change the page name for the root frame navigation in a Windows 10 UWP app?
body: <p>I have an <code>App.xaml</code> file that sets the root visual to be a <code>Frame</code> and then immediately navigates to a page called <code>Shell.xaml</code>. Inside <code>Shell.xaml</code> I have implemented a hamburger menu and have another <code>Frame</code> control where the main application's navigation is taking place.</p>
  
  <p>I am using Application Insights to track telemetry within the application. I wired up the <code>Navigated</code> event on the <code>Frame</code> nested within <code>Shell.xaml</code> and add a <code>TrackPageView</code> event within there to track all page navigations in one place. This is really nice because I don't have to do it in the <code>OnNavigatedTo</code> override in every single page.</p>
  
  <p>Here is the implementation of that <code>OnNavigatedToPage</code> event:</p>
  
  <pre><code>private void OnNavigatedToPage(object sender, NavigationEventArgs e)
  {
      var pageName = e.Content.GetType().Name;
      ViewModelDispatcher.Telemetry.TrackPageView(pageName);
  
      // After a successful navigation set keyboard focus to the loaded page
      if (e.Content is Page &amp;&amp; e.Content != null)
      {
          var control = (Page)e.Content;
          control.Loaded += Page_Loaded;
      }
  }
  </code></pre>
  
  <p>The problem is this works for every page <strong>except</strong> for the initial navigation to the <code>Shell.xaml</code>. </p>
  
  <p>When I look at Application Insights I get a nice list of pages that have been browsed to:</p>
  
  <ul>
  <li>AwesomeView</li>
  <li>AnotherCoolView</li>
  <li>MyView</li>
  <li><strong>application:MyRootNamespacePrefix.Shell</strong></li>
  </ul>
  
  <p>Call me OCD but my elegant implementation in the nested shell produces very nice and clean page names that correspond to just the class name of the XAML view. I omit all the nasty namespace prefix. However, the navigation to Shell does not. </p>
  
  <p>It should be noted that I am not calling the <code>TrackPageView</code> anywhere else in the application so I am assuming that somehow the Application Insights framework code is picking it up auto-magically.</p>
  
  <p>How do I change it so that my Shell doesn't have the nasty <code>application:MyRootNamespacePrefix.</code> in front of the actual class name?</p>
  
  <p><strong>UPDATE:</strong> 
  Eureka! It looks like I was right. The Application Insights Framework must be adding a hook to the root visual's Navigated event if it happens to be a Frame. All I did was add the same handler to the root frame that I added to the nested frame and it started showing up as "Shell". Unfortunately, application insights appears to add its own handler for the <code>Navigated</code> event of the root visual so while I get my nice clean PageView for "Shell" I also get the one with the nasty prefix.</p>