public MainWindow() { InitializeComponent(); DataContext = this; Groups = new ObservableCollection<Group>(); for (int g = 1; g < 6; g++) { var cg = new Group { Name = string.Format("Group {0}", g) }; Groups.Add(cg); for (int c = 1; c < 6; c++) { var cc = new Category { Name = string.Format("Category {0}-{1}", g, c) }; cg.Categories.Add(cc); for (int p = 1; p < 6; p++) { var cp = new Pattern { Name = string.Format("Pattern {0}-{1}-{2}", g, c, p) }; cc.Patterns.Add(cp); } } } }
public void Add(Category c) { c.Parent = this; Categories.Add(c); }