public static List <ChooserViewModel> CreateChooser() { if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) { return(new List <ChooserViewModel>()); } ChooserViewModel root = new ChooserViewModel("All Items", "All Items"); foreach (string categoryPath in SavedObjectInfoLookup.Categories) { string[] path = categoryPath.Split('\\'); ChooserViewModel newroot = root; ChooserViewModel oldroot = root; foreach (string s in path) { newroot = newroot.getChild(s); if (newroot == null) { newroot = new ChooserViewModel(s, s); oldroot.Children.Add(newroot); } oldroot = newroot; } oldroot._category = categoryPath; } root.Initialize(); return(new List <ChooserViewModel> { root }); }
private ChooserViewModel getByPath(string[] path) { ChooserViewModel current = this; foreach (string s in path) { current = current.getChild(s); if (current == null) { return(null); } } return(current); }