title: sorting a bound ItemsControl in a DataTemplate (XAML only)
body: <p>Is there a XAML only way to automatically sort the bound items (list of ViewModel object) ItemsControl based on one of the properties of the items. The ItemsControl is part of a DataTemplate. I thought CollectionViewSource would do the trick, but how do I bind the CollectionViewSource to the ItemsControl. The follwoing code dispays nothing:</p>
  
  <pre><code>&lt;--xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"--&gt;
      &lt;DataTemplate DataType="{x:Type vm:Company}"&gt;
          &lt;DataTemplate.Resources&gt;
              &lt;CollectionViewSource x:Key="viewSource" Source="{Binding Employees}"&gt;
                  &lt;CollectionViewSource.SortDescriptions&gt;
                          &lt;scm:SortDescription PropertyName="ID" /&gt;
                      &lt;/CollectionViewSource.SortDescriptions&gt;
              &lt;/CollectionViewSource&gt;
          &lt;/DataTemplate.Resources&gt;
          &lt;Viewbox&gt;
              &lt;ItemsControl ItemsSource="{Binding Source={StaticResource viewSource}}"&gt;
                   &lt;ItemsControl.ItemsPanel&gt;
                      &lt;ItemsPanelTemplate&gt;
                          &lt;StackPanel Orientation="Horizontal"/&gt;
                      &lt;/ItemsPanelTemplate&gt;
                  &lt;/ItemsControl.ItemsPanel&gt;
              &lt;/ItemsControl&gt;
          &lt;/Viewbox&gt;
      &lt;/DataTemplate&gt;
  </code></pre>