private void StartSortWorker() { _log.Info("Initializing the SortWorker"); _sortWorker = new BackgroundWorker(); _sortWorker.DoWork += (s, e) => { if (!_sortOrder.HasValue || !_sortOrder.Value) { _sortOrder = true; Textures = new BindableCollection <TextureItemViewModel>(_textures.OrderBy(x => x.Model.FileNameWithoutExtension)); } else if (_sortOrder.Value) { _sortOrder = false; Textures = new BindableCollection <TextureItemViewModel>(_textures.OrderByDescending(x => x.Model.FileNameWithoutExtension)); } }; _sortWorker.RunWorkerCompleted += (s, e) => { SetStatus(); NotifyOfPropertyChange(() => TexturesToShow); }; _log.Info("Starting the SortWorker"); _sortWorker.RunWorkerAsync(); }
/// <summary> /// in place sort an <see cref="IObservableCollection{T}"/> utilizing an <see cref="IComparer{T}"/> /// </summary> /// <remarks> /// will undo selection, when collection is bound for example to a ListBox /// </remarks> public static void Sort <T>(this IObservableCollection <T> collection, IComparer <T> comparer) { var sorted = collection.OrderBy(x => x, comparer).ToList(); for (var i = 0; i < sorted.Count; i++) { collection.Move(collection.IndexOf(sorted[i]), i); } }
private void ContributorsReceived(IEnumerable<Contributor> r) { Contributors = new BindableCollection<Contributor>(r); Contributors.OrderBy(c => c.Contributions); NotifyOfPropertyChange(() => Contributors); }
private void ContributorsReceived(IEnumerable <Contributor> r) { Contributors = new BindableCollection <Contributor>(r); Contributors.OrderBy(c => c.Contributions); NotifyOfPropertyChange(() => Contributors); }