title: Pivot with many PivotItems
body: <p>I'm developing a TV listing app for WP7, but I'm experiencing issues with the Pivot control: I tried at first to add all the available EPG channels, but performance are extremely poor (even on the real phone), taking ~10-15sec to add 25 <strong>empty</strong> PivotItems, without any data or control.</p>
  
  <p>So I tested a dynamic/lazy load oriented approach that loads only three items at first and then adds one more each time the user swipes left or right. Problem is, when swiping left the new item pushes the current one in the databound collection one slot to the right, producing a messy rendering on screen: <strong>that's not surprising, since SelectedIndex doesn't change, but selected item does</strong>. However, fixing SelectedIndex makes things even worse, resulting in Pivot to get stuck in an inconsistent layout.</p>
  
  <p>Here's the code:   </p>
  
  <pre><code>    public void ChangeChannel(){
  
          if (index &lt; 0) return;
          int i = index;
          int tot = Epg.Channels.Count;
          int slack = (i == 0) ? -1 : i &gt; oldIndex ? 1 : -1;
  
          var ch = this.Channels[i];
          var nextIndex = (ch.ChannelIndex + slack) % tot;
          if (nextIndex &lt; 0) nextIndex += tot;
  
          var next = Epg.Channels[nextIndex];
          if (!this.Channels.Contains(next))
          {
              if (slack &lt; 0)
              {
                  this.Channels.Insert(0, next);
                  //Index++;
              }
              else
                  this.Channels.Add(next);
          }
  
          oldIndex = i;
      }
  </code></pre>
  
  <p>Method is associated to Pivot.LoadingPivotItem by means of Caliburn.Micro. <em>index</em> is bound to Pivot.SelectedIndex, <em>Epg.Channels</em> is the primary model object and <em>this.Channels</em> is an ObservableCollection bound to Pivot.ItemsSource</p>
  
  <p><strong>EDIT: Found the trick.</strong> I got suspicious when I recalled I have a RSS Reader app that has a Pivot with no less than 10-12 tabs working really fast. That said, I built a little test app working similarly but without using Caliburn. Oh, that's some performance! But is Caliburn so heavy? Not really, since I discovered this little piece of code in the default AppBootstrapper:</p>
  
  <pre><code>            ConventionManager.AddElementConvention&lt;Pivot&gt;(Pivot.ItemsSourceProperty, "SelectedItem", "SelectionChanged").ApplyBinding =
              (viewModelType, path, property, element, convention) =&gt;
              {
                  if (ConventionManager
                      .GetElementConvention(typeof(ItemsControl))
                      .ApplyBinding(viewModelType, path, property, element, convention))
                  {
                      ConventionManager
                          .ConfigureSelectedItem(element, Pivot.SelectedItemProperty, viewModelType, path);
                      ConventionManager
                          .ApplyHeaderTemplate(element, Pivot.HeaderTemplateProperty, viewModelType);
                      return true;
                  }
  
                  return false;
              };
  </code></pre>
  
  <p>Removing it boosts performance, without having to quit Caliburn. Yeah, I know, that is something to investigate further, but for now it fixed all the stuff.</p>