private void DeleteThisSectionButton_Click(object sender, RoutedEventArgs e) { SectionTemplateItem sti = (SectionTemplateItem)this.Parent; PageTemplateItem pti = (PageTemplateItem)sti.Parent; pti.PageTemplate.Sections.Remove(SectionTemplate); }
private void DeleteThisArticleButton_Click(object sender, RoutedEventArgs e) { ArticleTemplateItem ati = (ArticleTemplateItem)this.Parent; SectionTemplateItem sti = (SectionTemplateItem)ati.Parent; sti.SectionTemplate.Articles.Remove(ArticleTemplate); }
private void Sections_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.OldItems != null) { // faire la liste des treeviewitem à supprimer var collectionForRemoval = from sti in Items.OfType <SectionTemplateItem>() where e.OldItems.Contains(sti.SectionTemplate) select sti; List <SectionTemplateItem> listForRemoval = collectionForRemoval.ToList(); listForRemoval.ForEach(toRemove => Items.Remove(toRemove)); } if (e.NewItems != null) { foreach (SectionTemplate st in e.NewItems) { SectionTemplateItem ste = new SectionTemplateItem(st); Items.Add(ste); } } }
private void InitTemplateTree() { PageTemplateItem pageRoot = new PageTemplateItem(Workflow.PageTemplate); ConfigTree.Items.Add(pageRoot); foreach (SectionTemplate st in Workflow.PageTemplate.Sections) { SectionTemplateItem sectionFolder = new SectionTemplateItem(st); pageRoot.Items.Add(sectionFolder); foreach (ArticleTemplate at in st.Articles) { /*ArticleTemplateEditor ate = new ArticleTemplateEditor() { ArticleTemplate = at }; * TreeViewItem articleLeaf = new TreeViewItem() { Header = ate };*/ ArticleTemplateItem articleLeaf = new ArticleTemplateItem(at); sectionFolder.Items.Add(articleLeaf); } } pageRoot.ExpandSubtree(); }