title: Convert PivotItem into Usercontrol to improve loading performance in WP7
body: <p>My MainPage.xaml is a pivot page with 3 PivotItems. Currently it is loading all of the necessary stuff for each of the PivotItems on the MainPage constructor. This is bad because it loads a lot of stuff that are not necessary.</p>
  
  <p>Reading <a href="http://tozon.info/blog/post/2011/08/12/Windows-Phone-Pivot-and-loading-content.aspx" rel="nofollow">here</a> and <a href="http://msdn.microsoft.com/en-us/library/ff941101%28v=vs.92%29.aspx" rel="nofollow">here</a> suggests that I only load the first PivotItem and after it loads, load the rest of the items. Specifically :</p>
  
  <blockquote>
    <p>Improve the performance of the pivot application by loading Pivot control content on-demand as opposed to loading everything at startup. One solution is to take the content from each PivotItem control and convert into UserControls. You can then subscribe to the LoadingPivotItem event on the root pivot control. Next, in the event handler, instantiate the proper UserControl and set it as the PivotItem content.</p>
  </blockquote>
  
  <p>If I follow the suggestion:</p>
  
  <pre><code>private void OnLoadingPivotItem(object sender, PivotItemEventArgs e)
  {
  if (e.Item.Content != null)
  {
      // Content loaded already
      return;
  }
  
  Pivot pivot = (Pivot)sender;
  
  if (e.Item == pivot.Items[0])
  {
      e.Item.Content = new Page1Control();
  }
  else if (e.Item == pivot.Items[1])
  {
      e.Item.Content = new Page2Control();
  }
  else if (e.Item == pivot.Items[2])
  {
      e.Item.Content = new Page3Control();
  }
  }
  </code></pre>
  
  <p>I should use create class PageXControl ? Should it inherit somehow from main-page class ?</p>
  
  <p>How do i take the content from each PivotItem control and convert into UserControls ?</p>
  
  <p>Thanks</p>