Sorting a ListBox of ListItems the WPF Way
Sorting a ListBox the C# WinForms way:
lstFooBar.sort = "true";
Sorting a ListBox the C# 4.0 Widows Presentation Foundation way:
lstFooBar.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Content", System.ComponentModel.ListSortDirection.Descending));
… this is an improvement?!
Note: You can also do this in the XAML. I haven’t tested it, but it’d look something like:
<CollectionViewSource.SortDescriptions> <dat:PropertySortDescription Direction="Descending" PropertyName="Content" /> </CollectionViewSource.SortDescriptions>