public override void HookEvents(IUIItemEventListener eventListener) { clickedTreeNodeHandler = AutomationElement.RegisterPropertyChangedEvent(TreeScope.Subtree, delegate { TreeNode node = ClickedNode; eventListener.EventOccured(new TreeNodeClickedEvent(this, node, node.IsExpanded())); }, ExpandCollapsePattern.ExpandCollapseStateProperty); selectedTreeNodeHandler = AutomationElement.RegisterPropertyChangedEvent(TreeScope.Subtree, delegate { TreeNode node = SelectedNode; eventListener.EventOccured((new TreeNodeSelectEvent(this, node))); }, SelectionItemPattern.IsSelectedProperty); }
public override void HookEvents(UIItemEventListener eventListener) { clickedTreeNodeHandler = delegate { TreeNode node = ClickedNode; eventListener.EventOccured((new TreeNodeClickedEvent(this, node, node.IsExpanded()))); }; selectedTreeNodeHandler = delegate { TreeNode node = SelectedNode; eventListener.EventOccured((new TreeNodeSelectEvent(this, node))); }; Automation.AddAutomationPropertyChangedEventHandler(automationElement, TreeScope.Subtree, clickedTreeNodeHandler, ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty); Automation.AddAutomationPropertyChangedEventHandler(automationElement, TreeScope.Subtree, selectedTreeNodeHandler, SelectionItemPatternIdentifiers.IsSelectedProperty); }