Hi, I have couple of questions on XamDataTree with CheckBox:
1. Currently, we can only check/uncheck the checkbox when click on the checkbox, is there a way to click on item, checkbox will be auto checked?
2. Select state and MouseOver state only change background color of an item, checkbox isn't included, can you provide sample to also highlight checkbox background?
3. How to change the foreground color of selected item.
Thanks,
Crystal.
You are welcome Crystal. Let me know if you have any other questions on the same.
Hi Maria, use dispatcher works, thank you so much for your help.
Hi Crystal,
Calling the Loop method in the loaded event of the tree is working on my side. I have attached the modified sample. Though it may be a timing issue that is causing the behavior on your side so that not all nodes are rendered. You can use a dispatcher in this case to change the priority of the Loop call to Backgroud. Let me know in case you need further assistance on the same.
Hi Maria, thank you for looking into this. when should I call this loop method. I tried to call it in Loaded event handler. it doesn't work.
Crystal
This behavior is caused by the fact that the parent nodes are initialized first and then the children. When the tree is loaded this will set the check state of the parent to unchecked as it is not bound to a property with the corresponding value. Then when the check state of a child node is set through the binding the parent does not corresponds to it. In order to make sure that the parent states are validated after the children are bound you can call the ValidateParentCheckedState method. Here is a code snippet for the same. You can call the Loop method after the tree is loaded:
public void Loop()
{
Action<XamDataTreeNodesCollection> accessNodes = null;
accessNodes = (nodes) =>
foreach (var n in nodes)
if (n.Manager.ParentNode != null)
n.Manager.ParentNode.ValidateParentCheckedState();
}
accessNodes(n.Nodes);
};
accessNodes(tree.Nodes);
I hope this will be helpful for you. Please let me know if you have any other questions.