How to synchronize sort markers between DataGrid and CollectionViewSource?
===

How do you achieve (preferably purely in XAML) that the sort marker in the column header of a WPF DataGrid is synchronized with the current sort order in a CollectionViewSource?

For example, I have the following example code which shows the attributes of all files in C:\, sorted by length:

    <Window x:Class="DataGridSortTest.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:cm="clr-namespace:System.ComponentModel;assembly=WindowsBase" 
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            <CollectionViewSource x:Key="items" Source="{Binding Files}">
                <CollectionViewSource.SortDescriptions>
                    <cm:SortDescription PropertyName="Length"/>
                </CollectionViewSource.SortDescriptions>
            </CollectionViewSource>
        </Window.Resources>
        <Grid>
            <DataGrid ItemsSource="{Binding Source={StaticResource items}}"/>
        </Grid>
    </Window>

The code-behind in MainWindow.xaml.cs is:

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            Files = Directory.GetFiles(@"C:\").Select(f => new FileInfo(f)).ToList();

            DataContext = this;
        }

        public IEnumerable<FileInfo> Files { get; private set; } 
    }

When I start this program it looks like this:

![Screenshot][1]

I.e. the files are sorted correctly, but the marker in the header is missing. With "marker", I mean this:

![Sort marker][2]

**NOTE**: I am looking for a **generic** solution. Just setting `DataGridColumn.SortDirection` is not a solution. I am looking for a way to instruct the DataGrid to automatically retrieve the sort order from the collection view.


  [1]: http://i.stack.imgur.com/jfMg5.png
  [2]: http://i.stack.imgur.com/G7JPn.png