title: Adding a PivotItem-derived class to a Pivot throws an exception
body: <p>UWP, C#. I have a <code>Pivot</code> control. I'm trying to add a <code>PivotItem</code>-derived object to the Items collection. It throws a <code>COMException</code>:</p>
  <blockquote>
  <p>No installed components were detected.</p>
  <p>Cannot apply a Style with TargetType 'Windows.UI.Xaml.Controls.PivotItem' to an object of type 'Windows.UI.Xaml.Controls.ContentControl'.</p>
  </blockquote>
  <p>The HRESULT is 0x800f1000, if that matters.</p>
  <p>Reproduces on a clean example. This works:</p>
  <pre><code>MyPivot.Items.Insert(1, new PivotItem() { Header = &quot;Boo&quot; });
  </code></pre>
  <p>And this exceptions:</p>
  <pre><code>MyPivot.Items.Insert(1, new BooItem() { Header = &quot;Boo&quot; });
  </code></pre>
  <p>Where <code>BooItem</code> is defined as</p>
  <pre><code>public class BooItem : PivotItem
  {
      public BooItem(){}
  }
  </code></pre>
  <p>If specified via XAML, the <code>PivotItem</code>-derived classes work in a <code>Pivot</code>. My other items in the app are all like that.</p>
  <p>The whole codebase is a port from Windows Phone Silverlight (targeting WP8.0), it worked over there. Now, UWP is not quite the same, but still, you'd expect...</p>
  <p>EDIT: you can add the item as invisible. The header will still appear, but the contents will be, well, invisible. Trying to make it visible causes the same exception.</p>
  <p>There's an interesting line in the <code>Pivot</code> docs:</p>
  <blockquote>
  <p>Any item you add to the Pivot that is not explicitly a PivotItem is implicitly wrapped in a PivotItem.</p>
  </blockquote>
  <p>Do objects that derive <code>PivotItem</code> count?</p>
  <hr />
  <p>EDIT2: reproduced on a blank project. The main page XAML goes:</p>
  <pre><code>&lt;Page
      x:Class=&quot;UWTest.MainPage&quot;
      xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
      xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
      xmlns:local=&quot;using:UWTest&quot;
      xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
      xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
      mc:Ignorable=&quot;d&quot;&gt;
  
      &lt;Pivot x:Name=&quot;ThePivot&quot;&gt;
          &lt;PivotItem Header=&quot;Foo&quot;&gt;
              &lt;StackPanel&gt;
                  &lt;Button Content=&quot;Go&quot; Click=&quot;OnGo&quot;/&gt;
              &lt;/StackPanel&gt;
          &lt;/PivotItem&gt;
          
      &lt;/Pivot&gt;
  &lt;/Page&gt;
  </code></pre>
  <p>The code behind goes:</p>
  <pre><code>using Windows.UI.Xaml;
  using Windows.UI.Xaml.Controls;
  namespace UWTest
  {
      public sealed partial class MainPage : Page
      {
          public MainPage()
          {
              this.InitializeComponent();
          }
  
          private void OnGo(object sender, RoutedEventArgs e)
          {
              ThePivot.Items.Insert(1, new BooItem() { Header = &quot;Boo&quot; });
          }
      }
      public class BooItem : PivotItem
      {
          public BooItem() { }
      }
  }
  </code></pre>
  <p>Visual Studio 2015 update 3, target version 14393, min version the same.</p>
  <p>EDIT: reproduced on another machine. Visual Studio 2015, brand new Unversal Windows C# project. Windows 10 Pro, v 1803 (build 17134.648).</p>