private void btnSort_Click(object sender, RoutedEventArgs e) { SortItem item = (sender as Button).Tag as SortItem; if (item != null) { SortTasks(item); } }
public void SortTasks(SortItem item, bool?desc = null) { ICollectionView view = CollectionViewSource.GetDefaultView(ViewModel.Tasks); if (view != null) { SortDescription sortDesc = CollectionHelper.SortCollection(view, item.Property, item.StartDescending); ViewModel.Sorts.SortBy(sortDesc.PropertyName, desc != null ? desc.Value : sortDesc.Direction == ListSortDirection.Descending); } }