This is a migrated thread and some comments may be shown as answers.

How do I check/uncheck each node in the Treeview in code

1 Answer 90 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Steve
Top achievements
Rank 1
Steve asked on 20 Mar 2012, 11:18 AM
Please can you tell me how I check/uncheck each node in a Treeview using code.

My TreeVieItems are created in the XAML and I am using the Visual Tree Helper to find each Treeview control, the Treeviews are returned but only contain one TreeVieItem?

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 22 Mar 2012, 07:39 AM
Hello Ben,

 

One of the approaches you can use is the TriStateMode of the RadTreeView.
You can set IsTriStateMode = True.
This way, when you select  a particular node - all of its direct and indirect children will get checked too. So you will need to only check the RadTreeViewItems from the root level collection. The RadTreeView.Items Collection will give you the root RadTreeViewItems when they are defined in XAML. So you can iterate over it, or you can also use RadTreeView.ItemContainerGenerator.ContainerFromIndex() method.
If you don't wish to use the TriState mode, you can traverse the tree and check every item. Please check out this help article describing a possible approach for traversing the tree hierarchy:
http://www.telerik.com/help/silverlight/radtreeview-how-to-iterate-through-treeviewitems.html 

Regards,
Petar Mladenov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
TreeView
Asked by
Steve
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or