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

2 posts, 0 answers
  1. Steve
    Steve avatar
    36 posts
    Member since:
    Feb 2011

    Posted 20 Mar 2012 Link to this post

    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?
  2. Petar Mladenov
    Petar Mladenov avatar
    3162 posts

    Posted 22 Mar 2012 Link to this post

    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: 

    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 >>
Back to Top