The docs for InitializeNode event says "This event is raised when a XamDataTreeNode is created."
I've been monitoring this event in the debugger (VS2010 & Infragistics 11.2) and it appears this event only gets raised as a node comes into view. This implies that a node only gets created when ever it comes into view.
On the other hand, the ScrollNodeIntoView Method says: "Scrolls a XamDataTreeNode into the viewable area.".
My dilemma is: Is nodes are created only when they are in view, how is it that ScrollNodeIntoView does what the documentation says it does?
As you can see, I need a better understanding of the XamDataTree.
Is there any documentation (Articles, etc.) that would provide better insight into the operation of XamDataTree?
Hi jgreene274,
Whenever something tries to access the data within a node, the XamDataTree will create the node if it hasn't been created yet. So for your question, in order to use the ScrollNodeIntoView method you need to supply a valid XamDataTreeNode object. When you search for that node it's data is accessed and if it hasnt been created yet, the tree will create the node and trigger the InitializeNode event. You can then use the node in the scroll method.
You can find more information about the XamDataTree here:http://help.infragistics.com/NetAdvantage/Silverlight/2011.2/CLR4.0/?page=xamDataTree.html
Let me know if you have any questions.
>>Whenever something tries to access the data within a node, the XamDataTree will create the node if it hasn't been created yet.
How can one access the data within a node without all ready having a referance to the node?
>>When you search for that node it's data is accessed and if it hasnt been created yet, the tree will create the node and trigger the InitializeNode event.
Oh, do you mean that I would search for the data using the search abilities of the Collection or Collection View Source that's attached to the XamDataTree through the ItemsSource property?
My scenario is this: my data is in an ObservableCollection which is the source for a CollectionViewSource which then is the ItemsSource for the XamDataTree. When I add an item to the ObservableCollection does that immediately trigger the creation of a XamDataTreeNode? If true, then I assume the InitializeNode event will be raised giving me access to the XamDataTreeNode and then I can ScrollNodeIntoView and set IsExpaned, etc.
The key thing I want to accomplish is when I add an object to my ObservableCollection I want to Scroll the node into view and have it expanded.
Thank you very much for your help!
Joe
Hi Rob,
I've been side tracked and unfortunately haven't attempted to implement your solution yet.
I think your solution works whenever a new item is added to the collection. In my scenario I first search for the item (level 0) and if found update it. If not found, then I add it.
I just haven't figured out the "search" case yet. I'm thinking I'll have to do a search on the CollectionViewSource since it is sorting, and get the index that way.
I realize this is not an Infragistics problem, but I'd be interested in your thoughts on this.
Hi Joe,
The way I would handle search functionality would be to iterate over the CollectionViewSource.View collection using a recursive function to check each node's children and return the XamDataTreeNode that can then be used in the ScrollNodeIntoView method. The code would look something like this:
You can then just call SearchForNode and if the return value is not null, you can pass it to the ScrollNodeIntoView method.
Hello Rob,
Thank you very much for the code. That looks like a great solution. Unfortunately, I've been tied up on other issues but hope to get back to this over the week-end if not sooner.
Thanks again,
Have you had a chance to re-visit this? Let me know if you have any questions.
Yes, with the understanding received from your sample, I was able to implement an even simpler sollution since I know my tree will never be more than 2 levels..