I want to make my tree disabled but still scrollable
I want the same thing with the TextEditor. Want to make it disabled but the user can still select the text, I thought the ReadOnly property was for that purpose, but it acts like the Enable property .....
We are building up a tree with checkboxes. Depending on the root object's state we wan't to restrict checking the checkboxes of the tree. Therefor we use:
((NodeCheckBoxUIElement)node.UIElement.ChildElements[1]).Enabled = false;
Our problem now is, that the UIElement of the node is only available after the node has fully finished its "layouting". This means, that UIElements are only created, if the node is currently shown in the tree. We tried to set the Enabled when entering the tree, but the UIElement property is only available on the top level nodes. The subNodes do not have an UIElement.
So we further registered to the "AfterExpand"-Event to enable the SubNodes, but actually also at this time the SubNodes do not have an UIElement-Property. If you register to "BeforeCheck" the Node has an UIElement to cancel the click, the UIElement property has the expected value. It seems like the tree is always recreating the UIElement when expanding the nodes.
So what we are missing is an event where we can set the enabled property of the NodeCheckBoxUIElement which is a child of the UIElement of the TreeNode. Something like "AfterNodeUIElementCreated".
private void EnableNodes(TreeNodesCollection treeNodesCollection, bool readOnly){ if (treeNodesCollection != null && treeNodesCollection.Count > 0) { foreach (UltraTreeNode node in treeNodesCollection) { if (node.UIElement != null) { ((NodeCheckBoxUIElement)node.UIElement.ChildElements[1]).Enabled = !readOnly; EnableNodes(node.Nodes, readOnly); } } }}
You should use the IUIElementCreationFilter interface for this.