title: WPF 4.0 TabControl with DataGrid view source unexpectantly changing
body: <p>I have a <code>TabControl</code> where each tab contains a <code>DataGrid</code>. When the user switches between tabs it seems that the <code>DataGrid</code> is created from scratch. I say this becuase of three things that I've noticed: the columns are automatticaly recreated, the current sorted column is lost, and selection is lost.</p>
  
  <p>I would love to be able to retain the current sorted view when the user returns to a tab page. They may be comparing lists and it doesn't make sense to have them resort each time. The databehind the scenes is not changing once it is created. However, the the tabs are bound to an observable collection because they need to be added/removed depending on how the application is being used.</p>
  
  <p><strong>ViewModel:</strong></p>
  
  <pre><code>public ObservableCollection&lt;DataTable&gt; Tables
  {
      get
      {
          return _tables; // Tables are added/removed through secondary methods
      }
  }
  </code></pre>
  
  <p><strong>View:</strong></p>
  
  <pre><code>&lt;TabControl ItemsSource="{Binding Path=Tables"}&gt;
      &lt;TabControl.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;TextBlock&gt;
                  &lt;TextBlock.Text&gt;
                      &lt;MultBinding StringFormat="{}{0} ({1})}&gt;
                          &lt;Binding Path="TableName"/&gt;
                          &lt;Binding Path="Rows.Count"/&gt;
                      &lt;/MultiBinding&gt;
                  &lt;/TextBlock.Text&gt;
              &lt;/TextBlock&gt;
          &lt;/DataTemplate&gt;
      &lt;/TabControl.ItemTemplate&gt;
      &lt;TabControl.ContentTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;DataGrid
                  AutoGeneratingColumns="True"
                  IsReadOnly="True"
                  ItemsSource="{Binding DefaultView}"
                  /&gt;
          &lt;/DataTemplate&gt;
      &lt;/TabControl.ContentTemplate&gt;
  &lt;/TabControl&gt;
  </code></pre>
  
  <p>Is there anyway to keep the current sort order of the datagrid when tabs are changed?</p>