Have CollectionViewSource
which will be wrapper over your actual collection and add SortDescription
in it. Bind ItemsSource
with CollectionViewSource instead.
Add CVS as a resource and bind like this:
<Grid>
<Grid.Resources>
<CollectionViewSource x:Key="SortedCollection"
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
Source="{Binding TempSol}">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription Direction="Descending"/>
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</Grid.Resources>
<ItemsControl ItemsSource="{Binding Source={StaticResource SortedCollection}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding }"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
Refer to the detailed explanation of using CollectionViewSource from MSDN here.