Exemple #1
0
        private void _coreCollection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case System.Collections.Specialized.NotifyCollectionChangedAction.Add:

                if (CollectionGroups?.Count > 0)
                {
                    foreach (var item in CollectionGroups.OfType <SelfServiceDependencyCollectionViewGroupBase>())
                    {
                        e.NewItems?.OfType <object>().ToList().Select(x => item?.TryAddItemToGroup(x)).ToArray();
                    }
                    e.NewItems?.OfType <object>().ToList().Select(x => GroupingManager?.TryAddItemToGroup(x)).ToArray();
                }
                RefreshPositionValues();
                break;

            case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
                break;

            case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                if (CollectionGroups?.Count > 0)
                {
                    foreach (var item in CollectionGroups.OfType <SelfServiceDependencyCollectionViewGroupBase>())
                    {
                        e.OldItems?.OfType <object>().ToList().Select(x => item?.TryRemoveItemFromGroup(x)).Any();
                    }
                    e.NewItems?.OfType <object>().ToList().Select(x => GroupingManager?.TryRemoveItemFromGroup(x)).ToArray();
                }
                RefreshPositionValues();
                break;

            case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
                break;

            case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
                if (CollectionGroups?.Count > 0)
                {
                    foreach (ICollectionViewGroup item in CollectionGroups)
                    {
                        item.GroupItems?.Clear();
                    }
                }
                RefreshPositionValues();
                break;

            default:
                break;
            }
        }