How can xamDataTree node's image can be controlled by datatriggers based on a value from viewmodel and treenodes are always expanded?
Hello,
One way to achieve the functionality you are looking for, to control the XamDataTree node's image, is through the use of converter. You can bind to a property in the ViewModel (e.g. custom property IsActive) and change the Image source depending on this property's value. You can use the converter in the CollapsedIconTemplate and ExpandedIconTemplate.
For your second question, you can load the XamDataTree with all the Nodes expanded, by recursively iterating through them:
private void ExpandAllNodes(IEnumerable<XamDataTreeNode> nodes, bool isExpandNode) { foreach (var node in nodes) { node.IsExpanded = isExpandNode; ExpandAllNodes(node.Nodes, isExpandNode); } }
To illustrate all this I have prepared a sample application.
If you need further assistance concerning this matter, please let me know.
Thanks Nick for the explanation of both questions and attachments, however, I would like image of the node to be changing at run time with underline property value changes. Thats why I wanted to do it via data triggers rather than a set value converter? How can I create that trigger?