I've a UserControl, which basically only contains a DataGrid.
In this DataGrid, I've a list of event(Severity - Date - Message).
The user controls is bound through the ViewModelLocator of MVVMLight Toolkit.
I've added two things:
In my UserControl resources:
<UserControl.Resources>
<CollectionViewSource x:Key="SortedEvents" Source="{Binding Events}">
<CollectionViewSource.SortDescriptions>
<componentModel:SortDescription PropertyName="EventTime" Direction="Descending"/>
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</UserControl.Resources>
which is used by the DataGrid:
<DataGrid ItemsSource="{Binding Source={StaticResource SortedEvents}}" AutoGenerateColumns="False" >
I also have the SortedDirection set on the DataGridTextColumn.SortDirection:
<DataGridTextColumn Binding="{Binding EventTime}" Header="Time" IsReadOnly="True" SortDirection="Descending"/>
When I check the designer, I see the small arrow showing that the DataGrid is sorted correctly.
But when I launch the application, the list is not sorted, the arrow is not here. If I click on the column to sort it, it sorts everything correctly, its just the default value which doesn't seems to work.
What am I missing? (This dataGrid/column are not even named, so I cannot try to edit them through something else).
(Initially I was only having the SortDirectionon the DataGridTextColumn. Same result)