Populating a tree with code works if the tree is on root, but not if tree is in a outlookbargroup. See attached code sample.
Hi Casper,
The reason it doesn't work from within the OutlookBarGroup is because of the way names work in XAML. More info can be found below but the gist of it is that the XamOutlookBar establishes its own namescope boundary so calling FindName from the Home page will not explore that part of the object tree. FindName is called automatically in order to fill in the names generated by the x:Name and Name XAML attributes. Since FindName can't reach the XamTree, the generated field that represents it in code-behind will be null.
MSDN article on how namescopes work:http://msdn.microsoft.com/en-us/library/cc189026(v=vs.95).aspx#UsingNamescopesatRuntime
Take a look at the first bullet point in the Remarks section:http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.findname(v=vs.95).aspx
In order to fix your sample so the tree is populated, you could use the sender that is passed as an argument to the Loaded event and cast that to a XamTree. Also, if you intend to use the XamTree elsewhere in code-behind you may just want to set the field manually. Add this line of code in your loaded event before you use the XamTree:
this.xamTree2 = sender as Infragistics.Controls.Menus.XamTree;
Now you can use the field xamTree2 in your code-behind without any issues. Let me know if you have any questions about this.
Thank Rob, I understand now, and it has solved my problem so far.
If I have questions towards the overall architecture of my application (i.e. which controls and how to use them - all Infragistics), is there a specific forum I can ask?
Let me know if you have any further questions on this matter.
On our forums we have sections seperated by controls so depending on which control you have questions on, you could create a new thread for it and we'll try and help you out. Alternatively you can open a private support request here http://es.infragistics.com/support/submitrequest.aspx.