private void RemoveHierarchicalElement() { var hierarchicalElement = Manager.SelectedElement as HierarchicalElementViewModel; if (hierarchicalElement?.ParentViewModel != null) { hierarchicalElement.ParentViewModel.Subitems.Remove(hierarchicalElement); } else { HierarchicalElements.Remove(hierarchicalElement); } }
private void AddHierarchicalElement() { var selectedHierarchicalElement = Manager.SelectedElement as HierarchicalElementViewModel; if (selectedHierarchicalElement != null) { var newItem = new HierarchicalElementViewModel(selectedHierarchicalElement) { Name = "Child Element" }; selectedHierarchicalElement.Subitems.Add(newItem); newItem.Selected = true; } else { var newItem = new HierarchicalElementViewModel(null) { Name = "Root Element" }; HierarchicalElements.Add(newItem); newItem.Selected = true; } }