As a follow-up to last week's blog posting and newsletter, this week I am going to show you how to use the CollectionViewSource object in Silverlight to sort data using code. Sometimes you need something a little more flexible, so you will need to resort to writing some code. You can take advantage of the CollectionViewSource from your XAML, but dynamically change the sort order of your lists with just a few lines of code.
If you are using Silverlight's ListBox control, you do not have to write code to sort your data. Instead you can use the built-in CollectionViewSource object in XAML to perform the sorting for you. This assumes that you are using a collection that implements the IEnumerable or IList interfaces.