Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected virtual void ApplySortCore(PropertyDescriptor property, ListSortDirection direction)
- {
- this.SortProperty = property;
- this.SortDirection = direction;
- if (direction == ListSortDirection.Ascending)
- {
- ResetItems(this.OrderBy(item => property.GetValue(item)).ToList());
- IsSorted = true;
- OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, property));
- }
- else if (direction == ListSortDirection.Descending)
- {
- ResetItems(this.OrderByDescending(item => property.GetValue(item)).ToList());
- IsSorted = true;
- OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, property));
- }
- }
- private void ResetItems(List<TItem> items)
- {
- base.ClearItems();
- foreach (var item in items)
- {
- base.InsertItem(IndexOf(item), item);
- }
- }
- protected virtual void ApplySortCore(PropertyDescriptor property, ListSortDirection direction)
- {
- this.SortProperty = property;
- this.SortDirection = direction;
- IEnumerable<T> items = null;
- if (direction == ListSortDirection.Ascending)
- {
- items = this.OrderBy(item => property.GetValue(item));
- }
- else
- {
- items = this.OrderByDescending(item => property.GetValue(item));
- }
- ResetItems(items.ToList ());
- IsSorted = true;
- OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, property));
- }
- private void ResetItems(IEnumerbale<TItem> items)
- {
- base.ClearItems();
- foreach (var item in items)
- {
- base.Add(item);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement