title: Changing selection of TabControl programatically works for content, but not for tab/header
body: <p>I have a <code>ListView</code> that allows me to select items, which are then added to an <code>ObservableCollection</code>.  This <code>ObservableCollection</code> is bound to a <code>TabControl</code>, so I get new tabs as I add items.  What I would like is for each new tab to become selected and show its content automatically.  </p>
  
  <p>From a content perspective, this is working.  I am able to see the newly-added item's content as expected, however from the looks of the <code>TabControl</code> itself, all tabs have been "deselected," or moved to the background.</p>
  
  <p>Here's what I'm doing:  (Note that I'm setting SelectedItem.  I experience similar results when setting SelectedIndex or SelectedValue.  Not sure what's best here.)</p>
  
  <pre><code>void MyCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
  {
      if (e.Action == NotifyCollectionChangedAction.Add)
      {
          List&lt;MyClass&gt; newStuff = e.NewItems.Cast&lt;MyClass&gt;().ToList&lt;MyClass&gt;();
  
          if (newStuff.Count == 1)
              myTabControl.SelectedItem = newStuff[0];
      }
  }
  </code></pre>
  
  <p>Using <code>Console.WriteLine</code> and the TabControl's SelectionChanged event, I can verify that the <code>TabControl.SelectedIndex</code> is changing as expected.  With each new item however, all tabs appear to move to the background.  </p>
  
  <p>I always see the content for the new item, but I must manually click the tab in order for it to visually appear as the foreground tab.</p>
  
  <p>Whenever I click the background tab that is supposed to already be in the foreground, my console often displays a redundant debug message.  </p>
  
  <p>For example, if I start with zero items in the collection and then add one, I get one background tab, one console message, and I see the item's content.  If I click on the tab, it comes to the foreground and the SelectionChanged method fires(!!!), repeating the same console message while I stare at the same item content:</p>
  
  <pre><code>myTabControl now has SelectedIndex of 0
  myTabControl now has SelectedIndex of 0
  </code></pre>
  
  <p>How can I both programmatically show the content of my new tab, and see that tab as the foreground tab?  </p>
  
  <p>The only way I can bring ANY tab to the foreground programmatically is by setting <code>myTabControl.SelectedIndex = -1</code>.  Apparently this is not an option while the <code>ObservableCollection</code> contains items, so this forces the <code>TabControl</code> to move the first tab (content, header and all) to the foreground.  What am I missing here?</p>
  
  <p><strong>Correction:</strong>  With this method (setting <code>SelectedItem</code>) I do get my very first tab in the foreground, however creating tab #2 and all subsequent tabs deselects all tabs, while showing the content from the most recent addition.</p>