title: Listbox live sort using CollectionViewSource on ObservableCollection
body: <p>I would like to enable live sorting of ListBox items bound to an ObservableCollection; I would also like to enable the live sorting exclusively via my XAML markup (if possible).  As things stand, the list is properly sorted on application startup, but items are simply appended (not sorted) to the ListBox when new items are added to the ObservableCollection.</p>
  
  <p>In my viewmodel I have the following public property:</p>
  
  <pre><code>public ObservableCollection&lt;Equipment&gt; EquipmentList { get; set; }
  </code></pre>
  
  <p><em>Equipment</em> is an auto-generated class from Entity Framework which contains a public string property named 'Description'.  This is my sort target.</p>
  
  <p>My XAML has the following DataTemplate which is intended to enable the live sorting:</p>
  
  <pre><code>&lt;DataTemplate x:Key="EquipmentDescriptionTemplate" 
                        DataType="{x:Type e:Equipment}"&gt;
      &lt;DataTemplate.Resources&gt;
          &lt;CollectionViewSource x:Key="SortedEquipmentList" 
                                Source="{Binding Path=Description, 
                                    Mode=OneWay, 
                                    UpdateSourceTrigger=PropertyChanged}" 
                                    IsLiveSortingRequested="True"&gt;
              &lt;CollectionViewSource.SortDescriptions&gt;
                  &lt;scm:SortDescription PropertyName="Description" 
                                       Direction="Ascending"/&gt;
              &lt;/CollectionViewSource.SortDescriptions&gt;
              &lt;CollectionViewSource.LiveSortingProperties&gt;
                  &lt;clr:String&gt;Description&lt;/clr:String&gt;
              &lt;/CollectionViewSource.LiveSortingProperties&gt;
          &lt;/CollectionViewSource&gt;
      &lt;/DataTemplate.Resources&gt;
      &lt;TextBlock Text="{Binding Path=Description}" /&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>And finally the XAML ListBox item:</p>
  
  <pre><code>&lt;ListBox x:Name="EquipmentList" 
       ItemsSource="{Binding Path=EquipmentList, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" 
       ItemTemplate="{StaticResource EquipmentDescriptionTemplate}" 
       IsSynchronizedWithCurrentItem="True" 
       SelectedItem="{Binding EquipmentSelection, UpdateSourceTrigger=PropertyChanged}" 
       Grid.ColumnSpan="2" Grid.Row="1" Margin="5,5,5,5"/&gt;
  </code></pre>
  
  <p>There's a lot of extra attributes which I added in my desperate attempts to get the live sorting to work (when in doubt, guess wildly!).  I've left them in so folks can see what I've tried, and snicker.</p>
  
  <p>How do I enable live ListBox sorting via XAML?</p>