Simple Listbox Ordering using a CollectionViewSource

history edit


As with most xaml based apps there are any number of ways of ordering a list of items. A quick and straightforward way to do this entirely in xaml is to use a CollectionViewSource.

The above example will order a bound list ‘List’ based on the listed object’s ‘Name’ property.

The SortDescription binding is clever enough to raise an error if the property selected doesn’t implement IComparable.

See also this example by Scott Hanselman.

And a mere six years ago Stack Overflow: How can I sort a ListBox using only XAML and no code-behind?