title: CollectionViewSource sorting only the first time it is bound to a source
body: <p>I'm using a DataGrid bound to a CollectionViewSource (<em>players</em>), itself bound to the currently selected item of a ListBox (<em>levels</em>), each item containing a collection to be sorted/displayed in the DataGrid:</p>
  
  <pre><code>&lt;ListBox Name="lstLevel"
           DisplayMemberPath="Name" 
           IsSynchronizedWithCurrentItem="True" /&gt;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>&lt;!-- DataGrid source, as a CollectionViewSource to allow for sorting and/or filtering --&gt;
  &lt;CollectionViewSource x:Key="Players" 
                        Source="{Binding ElementName=lstLevel, 
                                         Path=SelectedItem.Players}"&gt;
    &lt;CollectionViewSource.SortDescriptions&gt;
      &lt;scm:SortDescription PropertyName="Name" /&gt;
    &lt;/CollectionViewSource.SortDescriptions&gt;
  &lt;/CollectionViewSource&gt;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>  &lt;DataGrid Name="lstPlayers" AutoGenerateColumns="False" 
              CanUserSortColumns="False"
              ItemsSource="{Binding Source={StaticResource Players}}"&gt;
      &lt;DataGrid.Columns&gt;
        &lt;DataGridTextColumn Header="Name"
                            Binding="{Binding Path=Name, Mode=TwoWay}"
                            Width="*" /&gt;
        &lt;DataGridTextColumn Header="Age"
                            Binding="{Binding Path=Age, Mode=TwoWay}"
                            Width="80"&gt;
        &lt;/DataGridTextColumn&gt;
      &lt;/DataGrid.Columns&gt;
    &lt;/DataGrid&gt;
  </code></pre>
  
  <p>(whole C# code <a href="http://pastebin.com/smc3t4TX" rel="noreferrer">here</a>, XAML code <a href="http://pastebin.com/i56cCFkF" rel="noreferrer">here</a>, entire test project <a href="http://www.4shared.com/file/mhSWeKN7/DataGridSort.html" rel="noreferrer">here</a> - in addition to the DataGrid I've added a simple ListBox for the players, to make sure it wasn't a DataGrid issue)</p>
  
  <p>The problem is that the players are sorted the first time they are shown, but as soon as I select another level from the ListBox, they are not sorted anymore. Also, modifying names the first time players are shown will sort them accordingly to the changes, but not anymore once the level has been changed.</p>
  
  <p>So it looks like changing the source of the CollectionViewSource somehow breaks the sort feature, but I have no idea why, nor how to fix it. Does anyone know what I'm doing wrong?</p>
  
  <p>(I did a test with a filter, but that one kept working as expected)</p>
  
  <p>The framework is .NET 4.</p>