title: MVVM Tabs: Focus new tab
body: <p>I can add &amp; remove tabs similar to the famous <a href="http://msdn.microsoft.com/en-us/magazine/dd419663.aspx" rel="nofollow">MSDN article</a>. Basically a <code>ObservableCollection&lt;TabViewModels&gt;</code>. And I add tabs like <code>_tabs.Add(new TabViewModel())</code> but the newest tab is not focused. I want to focus it. How do I do it?</p>
  
  <p><strong>1 way to do it</strong></p>
  
  <p>since i have a view source for my observable collection, I can do the below... another option will be @vorrtex method</p>
  
  <pre><code>public void OnTabsChanged(object sender, NotifyCollectionChangedEventArgs e)
  {
      if (e.NewItems != null &amp;&amp; e.NewItems.Count &gt; 0)
          foreach (TabViewModel tab in e.NewItems)
          {
              tab.CloseRequested += OnCloseRequested;
              _tabsViewSource.MoveCurrentTo(tab);
          }
      if (e.OldItems != null &amp;&amp; e.OldItems.Count &gt; 0)
          foreach (TabViewModel tab in e.OldItems)
              tab.CloseRequested -= OnCloseRequested;
  }
  </code></pre>