void ucMaintain_DeleteCompleted(object sender, ECDynamicCategoryActionEventArgs e) { var targetNode = e.Data; if (targetNode != null) { var selected = this.tvECDynamicCategoryTree.SelectedItem as TreeViewItem; if (selected != null) { var parent = selected.Parent as TreeViewItem; if (parent != null) { if (this.QueryVM.IsOnlyShowActive) { parent.Items.Remove(selected); } else { var foreColor = Colors.Red; selected.Foreground = new SolidColorBrush(foreColor); } } } } }
void ucMaintain_EditCompleted(object sender, ECDynamicCategoryActionEventArgs e) { var targetNode = e.Data; if (targetNode != null) { if (targetNode.Status == DynamicCategoryStatus.Deactive && this.cbShowActiveOnly.IsChecked == true) { //删除选中的节点 var parent = this.tvECDynamicCategoryTree.GetParentItem(this.tvECDynamicCategoryTree.SelectedItem) as TreeViewItem; if (parent != null) { parent.Items.Remove(this.tvECDynamicCategoryTree.SelectedItem); } } else { Color foreColor = Colors.Black; if (targetNode.IsDeActive) { foreColor = Colors.Red; } //更新节点的名称 var selected = this.tvECDynamicCategoryTree.SelectedItem as TreeViewItem; if (selected != null) { selected.Header = string.Format("[{0}]{1}", targetNode.SysNo, targetNode.Name); selected.Foreground = new SolidColorBrush(foreColor); } selected.Tag = e.Data.DeepCopy().ConvertVM <ECDynamicCategoryVM, ECDynamicCategory>(); } } }
void ucMaintain_AddCompleted(object sender, ECDynamicCategoryActionEventArgs e) { var targetNode = e.Data; var entity = targetNode.ConvertVM <ECDynamicCategoryVM, ECDynamicCategory>(); if (targetNode != null) { var selected = this.tvECDynamicCategoryTree.SelectedItem as TreeViewItem; if (selected != null) { var item = new TreeViewItem { Header = string.Format("[{0}]{1}", targetNode.SysNo, targetNode.Name), Tag = entity }; selected.Items.Add(item); this.tvECDynamicCategoryTree.SelectItem(item); } } }