We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Silverlight TreeViewAdv nodes not populated

I am trying to set default node visibility in a TreeViewAdv to only the top N levels programmatically. This treeview has an ObservableCollection ItemsSource and uses a data template for display. It seems that each level's child nodes aren't populated in the TreeViewAdv.Nodes collection until they otherwise become visible. With the following code example if all nodes aren't expanded by default (with the TreeViewAdv.IsExpanded property), then it only sees a Nodes collection for the top node pointed to by our collection. However if I do expand all nodes in the treeviewadv property, then it finds all the nested child nodes. How can I access the child nodes when they aren't yet visible? I don't want to make them all visible then shrink to the default view because it is confusing to a user.


void expandToLevel(int level)
{
if (chartTree.Nodes.Count > 0)
{ handleCurrentNode(chartTree.Nodes[0], level, 0); }
}

void handleCurrentNode(TreeViewItemAdv node, int expandToLevel, int currentlevel)
{
node.IsExpanded = (currentlevel < expandToLevel);
foreach (TreeViewItemAdv child in node.Nodes)
{
handleCurrentNode(child, expandToLevel, currentlevel + 1);
}
}



1 Reply

KL Karthikeyan L Syncfusion Team December 7, 2011 07:43 PM UTC

Hi Darryl,

Thank you for showing interest on Syncfusion products.

Using the IsExpanded property and IsVisibility property the expanded mode and visibility of TreeViewAdv can be set. By binding these property of the TreeViewAdv will simplify the usage of properties inside codebehind. We have prepared a sample based on your requirement and we have attached for your reference.

Sample link: http://www.syncfusion.com/downloads/Support/DirectTrac/General/TreeViewVisibility1660423607.zip

Let us know if you have any other queries.

Thank you,
Karthikeyan.



Loader.
Live Chat Icon For mobile
Up arrow icon