Programmatically activate a node in Infragistics XamDataTree
I'm using Infragistics NetAdvantage for Win Client 2010 Vol. 3.
I made a WPF User Control that shows some nested items using a XamDataTree control. Tree nodes are loaded from a binded Obs开发者_StackOverflow中文版ervable item collection:
MenuNode menuTree = getMenuTree(true);
ObservableCollection<MenuNode> menuNodes = menuTree.children;
this.treeFP.ItemsSource = menuNodes;
I couldn't find a suitable tree method that activates a node based on certain property (eg. a key?). So I created a method that loops through the whole tree, until it finds the correct node to activate:
void selectNode(XamDataTreeNodesCollection nodes, string nodeKey)
I then called this method in this way:
selectNode(theTree.Nodes, "KEYTOSELECT");
It turned out that theTree.Nodes collection is empty! Why? Probably because items source is binded? If this behaviour is correct (?), is there another way to activate a single node?
It is a problem of asynchronous loading of tree nodes. Method 'selectNode' must be called from tree_Loaded event handler and it works.
Here's a more detailed answer: http://forums.infragistics.com/forums/t/56486.aspx.
精彩评论