void AddFromDictionary(Dictionary <string, IEnumerable <string> > dict) { foreach (KeyValuePair <string, IEnumerable <string> > kvp in dict) { TreeViewItem section = RegexTitleTreeView.TreeViewItemWithHeader(kvp.Key); if (section == null) { section = new TreeViewItem() { Header = kvp.Key }; RegexTitleTreeView.Items.Add(section); System.Diagnostics.Debug.WriteLine($"AddingSection {kvp.Key}"); } foreach (string s in kvp.Value) { if (!section.ContainsChildHeader(s)) { System.Diagnostics.Debug.WriteLine($"Adding {kvp.Key}/{s}"); section.Items.Add(new TreeViewItem() { Header = s }); } else { System.Diagnostics.Debug.WriteLine($"Skip {kvp.Key}/{s}"); } } } RegexTitleTreeView.RefreshTextBoxes(); }