public MainWindow() { InitializeComponent(); TreeNode root = new TreeNode(); root.Header = "root"; tree1.Items.Clear(); // add node to tree before adding handlers, or you'll get // a StackOverflowException tree1.Items.Add(root); root.AddHandler(TreeNode.ExpandedEvent, new RoutedEventHandler(expandedHandler)); }
private void newNodeCopyExpandedHandlers(TreeNode node) { TreeNode newNode = new TreeNode(); newNode.Header = "nuovo!"; // add node to tree before adding handlers, or you'll get // a StackOverflowException tree1.Items.Add(newNode); foreach (Delegate d in newNode.GetHandlers(node, TreeNode.ExpandedEvent)) { newNode.AddHandler(TreeNode.ExpandedEvent, d); } }