Sorting a WPF ListBox on a Converted Value? | Programming, .NET, Silverlight & More

Sorting a WPF ListBox on a Converted Value?

In WPF, is it possible to apply a Converter to the SortDescription of a CollectionViewSource? My ViewModel contains a List<> of a class that contains an enum and a Boolean. My XAML displays a multi-select ListBox, showing the localized names of the enum values using a Converter in the View, and binds each ListBoxItem’s IsSelected to the Boolean in the members of the bound List<>. That’s working. Now I want to sort the ListBox items by those localized enum names, without reordering the List<> in the ViewModel. How can this be done?

I’m not sure it can be done directly. The brute force and ignorance way I would tackle it with is to populate another list and sort that (or indeed populate a sorted list).

No TweetBacks yet. (Be the first to Tweet this post)

One Response

  1. WaMSie Says:

    I’m not sure it can be done directly. The brute force and ignorance way I would tackle it with is to populate another list and sort that (or indeed populate a sorted list).
    References :

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.