public void SetRootItem(ProjectItem root) { if (root == null) { _RootItem = null; _First.Clear(); return; } SetProject(root, this); _RootItem = new ProjectItemViewModel(root); _First.Clear(); _First.Add(_RootItem); }
public void EventClear() { //**************************************** var MyRecords = new ObservableSortedList <int, int>(); NotifyCollectionChangedEventArgs MyEventArgs = null, MyKeyEventArgs = null, MyValueEventArgs = null; //**************************************** MyRecords[10] = 42; MyRecords.CollectionChanged += (sender, e) => MyEventArgs = e; MyRecords.Keys.CollectionChanged += (sender, e) => MyKeyEventArgs = e; MyRecords.Values.CollectionChanged += (sender, e) => MyValueEventArgs = e; MyRecords.Clear(); //**************************************** Assert.AreEqual(0, MyRecords.Count, "Items not cleared"); Assert.IsNotNull(MyEventArgs, "No Event Raised"); Assert.AreEqual(NotifyCollectionChangedAction.Reset, MyEventArgs.Action); Assert.IsNotNull(MyKeyEventArgs, "No Key Event Raised"); Assert.AreEqual(NotifyCollectionChangedAction.Reset, MyKeyEventArgs.Action); Assert.IsNotNull(MyValueEventArgs, "No Value Event Raised"); Assert.AreEqual(NotifyCollectionChangedAction.Reset, MyEventArgs.Action); }
public void SetGrid(Interop.Grid grid) { GridItemViewModel vm = CreateGridViewModel(grid); _Grid.Clear(); _Grid.Add(vm); }
private void HandlePageCollectionChanges(object sender, NotifyDictionaryChangedEventArgs <string, TaggedPage> e) { Action a = null; switch (e.Action) { case NotifyDictionaryChangedAction.Add: a = () => _pages.AddAll(from i in e.Items select new HitHighlightedPageLinkModel(i, _highlighter, OneNoteApp)); break; case NotifyDictionaryChangedAction.Remove: a = () => _pages.RemoveAll(from i in e.Items select i.Key); break; case NotifyDictionaryChangedAction.Reset: a = () => _pages.Clear(); break; } if (a != null) { Dispatcher.Invoke(new Action(() => { a(); fireNotifyPropertyChanged(PAGE_COUNT); })); } }