protected override TreeViewItem BuildRoot() { //Reset variables and create Root node. ids = 0; rows.Clear(); var root = new TreeViewItem(-1, -1, "Root"); if (entityManager.IsCreated) { var entities = entityManager.GetAllEntities().ToArray(); foreach (var entity in entities) { var entityItem = new EntityElement(ids++, entity); rows.Add(entityItem); foreach (var type in entityManager.GetComponentTypes(entity)) { var ctype = new ComponentElement(type, ids++, 1); rows.Add(ctype); entityItem.AddChild(ctype); } root.AddChild(entityItem); } } root.AddChild(new TreeViewItem(1)); SetupDepthsFromParentsAndChildren(root); return(root); }