Hi,
I have a XamDataTree where I use the public function "ScrollNodeIntoView" to bring the node into the view.
The thing is the node is always scrolled at the top of the view or the bottom of the view ( depends where the node is in the tree).
Is there any possibilities to scroll the node right in the middle of the view of the XamDataTree ?
Thanks in advance.
Hello Peray,
There does not currently exist a built-in method to the XamDataTree to scroll a node into the middle of the view of that tree. This can be implemented with some app-code, though, in that you could find the number of nodes that are in view and then scroll that number of nodes divided by 2 either up or down depending on where your node exists.
To get the number of nodes in view, I would recommend using the Infragistics.Windows.Utilities class and its static GetDescendantFromName method to get a NodesPanel object named "NodesPanel." This panel's Children collection will be full of XamDataTreeNodeControl elements, which only get created for nodes that are in view. By looping through this collection and checking each XamDataTreeNodeControl.Node, you can get a list of the nodes that are in view, as well as the indices of these nodes as there is an Index property on each Node.
Knowing this, you can check the Index of the node that you are looking to bring into view and scroll minus your number of nodes in view / 2 if the node is above, or plus your number of nodes in view / 2 if the node is below.
I have attached a sample project to demonstrate the above. I hope this helps.
Please let me now if you have any other questions or concerns on this matter.
XamDataTreeScrollNodeToMiddleCase.zip
Hello Andrew,
Thanks you for your fast answer. It worked like a charm.
The only thing I changed is to get the master node index instead of the active one ( because I have three levels of nodes ) to get the right position in the tree.
Again, thanks for the sample and the answer.
Best Regards,
Sébastien.