예제 #1
0
        private void fetchTopics()
        {
            AllTopics = new ObservableCollection <Topic>();
            AllTopics = new ObservableCollection <Topic>(dbh.GetAllTopics());
            NotifyPropertyChanged("AllTopicGroups");

            AllTopicGroups = new GroupedObservableCollection <string, Topic>(c => c.sectionId.ToString(), AllTopics.ToList());
            NotifyPropertyChanged("AllTopicGroups");
        }
        public GroupedObservableCollection <TKey, TElement> ReplaceWith(GroupedObservableCollection <TKey, TElement> replacementCollection, IEqualityComparer <TElement> itemComparer)
        {
            // First make sure that the top level group containers match
            var replacementKeys = replacementCollection.Keys.ToList();
            var currentKeys     = new HashSet <TKey>(this.Keys);

            this.RemoveGroups(currentKeys.Except(replacementKeys));
            this.EnsureGroupsExist(replacementKeys);

            Debug.Assert(this.Keys.SequenceEqual(replacementCollection.Keys), "Expected this collection to have exactly the same keys in the same order at this point");

            for (var i = 0; i < replacementCollection.Count; i++)
            {
                MergeGroup(this[i], replacementCollection[i], itemComparer);
            }

            return(this);
        }