public Form1() { InitializeComponent(); ButtonMenu bm1 = new ButtonMenu(this.wpfTreeView1); ButtonMenu bm2 = new ButtonMenu(this.wpfTreeView1); bm1.AddButtonItems(new ButtonItem(newImage, "New File", new ButtonItemClickEventHandler(newFileClick))); bm1.AddButtonItems(new ButtonItem(openImage, "Open File", new ButtonItemClickEventHandler(openFileClick))); bm2.AddButtonItems(new ButtonItem(saveImage, "Save File", new ButtonItemClickEventHandler(saveFileClick))); bm2.AddButtonItems(new ButtonItem(deleteImage, "Delete File", new ButtonItemClickEventHandler(deleteFileClick))); bm2.AddButtonItems(new ButtonItem(copyImage, "Save File", new ButtonItemClickEventHandler(copyFileClick))); WpfTreeNode root = this.wpfTreeView1.AddWPFTreeNode("WpfTreeView Demo"); WpfTreeNode child1 = root.AddWPFTreeNode("节点1", bm1); WpfTreeNode child1_1 = child1.AddWPFTreeNode("节点1-1", bm2); child1_1.AddWPFTreeNode("1"); child1_1.AddWPFTreeNode("2"); child1_1.AddWPFTreeNode("3"); child1.AddWPFTreeNode("节点1-2", bm2); WpfTreeNode child2 = root.AddWPFTreeNode("节点2", bm1); child2.AddWPFTreeNode("节点2-1", bm2); WpfTreeNode child3 = root.AddWPFTreeNode("节点3", bm1); child3.AddWPFTreeNode("节点2-1", bm2); this.wpfTreeView1.ExpandAll(); }
public WpfTreeNode AddWPFTreeNode(string text, ButtonMenu buttons) { WpfTreeNode node = new WpfTreeNode(text, buttons); this.Nodes.Add(node); return(node); }
public WpfTreeNode(string text, ButtonMenu buttonMenu) : base(text) { this._buttonMenu = buttonMenu; MouseEnterEvent += new TreeNodeMouseEnterEventHandler(MouseEnter); MouseLeaveEvent += new TreeNodeMouseLeaveEventHandler(MouseLeave); }