protected IDisposable DeferResortHelper( IEnumerable itemsSourceCollection, CollectionView collectionView) { var dataGridCollectionView = itemsSourceCollection as DataGridCollectionViewBase; if (dataGridCollectionView != null) { return(dataGridCollectionView.DataGridSortDescriptions.DeferResort()); } ColumnSortCommand.ThrowIfNull(collectionView, "collectionView"); return(collectionView.DeferRefresh()); }
protected void SynchronizeColumnSort( SynchronizationContext synchronizationContext, SortDescriptionCollection sortDescriptions, ColumnCollection columns) { ColumnSortCommand.ThrowIfNull(synchronizationContext, "synchronizationContext"); ColumnSortCommand.ThrowIfNull(sortDescriptions, "sortDescriptions"); ColumnSortCommand.ThrowIfNull(columns, "columns"); if (!synchronizationContext.Own || !columns.Any()) { return; } this.SetResortCallback(sortDescriptions, columns); int count = sortDescriptions.Count; Dictionary <string, ColumnSortInfo> sortOrder = new Dictionary <string, ColumnSortInfo>(count); for (int i = 0; i < count; i++) { var sortDescription = sortDescriptions[i]; string propertyName = sortDescription.PropertyName; if (sortOrder.ContainsKey(propertyName)) { continue; } sortOrder.Add(propertyName, new ColumnSortInfo(i, sortDescription.Direction)); } foreach (var column in columns) { ColumnSortInfo entry; if (sortOrder.TryGetValue(column.FieldName, out entry)) { column.SetSortIndex(entry.Index); column.SetSortDirection(entry.Direction); } else { column.SetSortIndex(-1); column.SetSortDirection(SortDirection.None); } } }