/// <summary> /// Synchronizes the group descriptions collection to the group descriptors collection. /// </summary> /// <param name="descriptor">The descriptor that changed</param> /// <param name="e">The property change event</param> private void HandleGroupDescriptorChanged(GroupDescriptor descriptor, PropertyChangedEventArgs e) { this._ignoreChanges = true; try { // We have to reset when the collections were not equal before the change if (this._sourceCollection.Count != this._descriptionCollection.Count) { GroupCollectionManager.ResetToGroupDescriptors(this._descriptionCollection, this._sourceCollection); } else { int index = this._sourceCollection.IndexOf(descriptor); GroupDescription description = GroupCollectionManager.GetDescriptionFromDescriptor(descriptor); if (description == null) { this._descriptionCollection.RemoveAt(index); } else { this._descriptionCollection[index] = description; } } } finally { this._ignoreChanges = false; } }
/// <summary> /// Determines whether the <paramref name="groupDescription"/> and <paramref name="groupDescriptor"/> are equivalent. /// </summary> /// <param name="groupDescription">The description to compare</param> /// <param name="groupDescriptor">The descriptor to compare</param> /// <returns><c>true</c> if the two are equivalent</returns> private static bool AreEquivalent(GroupDescription groupDescription, GroupDescriptor groupDescriptor) { Debug.Assert((groupDescription != null) && (groupDescriptor != null), "Both should be non-null."); PropertyGroupDescription propertyGroupDescription = groupDescription as PropertyGroupDescription; if (propertyGroupDescription == null) { return false; } return (propertyGroupDescription.PropertyName == groupDescriptor.PropertyPath); }
/// <summary> /// Returns a <see cref="GroupDescription"/> equivalent to the specified descriptor. /// </summary> /// <param name="groupDescriptor">The descriptor to get a description from</param> /// <returns>A <see cref="GroupDescription"/> equivalent to the specified descriptor</returns> private static GroupDescription GetDescriptionFromDescriptor(GroupDescriptor groupDescriptor) { if (string.IsNullOrEmpty(groupDescriptor.PropertyPath)) { return null; } return new PropertyGroupDescription(groupDescriptor.PropertyPath); }