Michael Sutton

Michael Sutton

  • NA
  • 17
  • 3.5k

Conditional Sort using ListCollectionView.SortDescriptions

Nov 7 2012 12:44 PM

I can successfully sort my collection using the following:

//Initialize collection view and set sort and filter properties
itemRelationshipsView = (ListCollectionView)CollectionViewSource.GetDefaultView(itemRelationships);
itemRelationshipsView.IsLiveSorting = true;
itemRelationshipsView.Filter = RootLevelFilter;
itemRelationshipsView.SortDescriptions.Add(new SortDescription("Item.Description", ListSortDirection.Ascending));
tvList.ItemsSource = itemRelationshipsView;


However, I need to make a special case, where if Item.Type = 1, then I need (new SortDescription("Item.Code",  ListSortDirection.Ascending));
to override the default "Item.Description" sort.

Any ideas?


 



 

 




 


 


 


Answers (1)