Checkbox Behavior

2 posts, 0 answers
  1. Adrian de Freitas
    Adrian de Freitas avatar
    1 posts
    Member since:
    Mar 2010

    Posted 30 Aug 2010 Link to this post

    I would like to be able to "couple" and "de-couple" the cascading behavior of a checkbox in the treeview at will.  Specifically, I am looking for the following:

    1.  Make it such that the topmost nodes in the tree (i.e. Level 1), when checked/unchecked, check/uncheck all underlying child nodes.
    2.  Make it such that all nodes at level 2 or below, when checked/unchecked, does NOT check/uncheck all parent OR child nodes.
    3.  Make it such that the topmost nodes in the tree (i.e. Level 1) are either checked, unchecked, or indeterminate, based on the checkstate of the underlying child nodes.

    Use Case:  I am using the treeview to describe a military chain of command in which the topmost nodes represent countries and all child nodes represent individual units (some units can have subordinate units under them which appear as children).  I want to bind the checkbox to the Visibility property of a control so that users can easily show/hide units by manipulating the checkboxes.  When they check the country checkbox, they should be able to show/hide all underlying units.  When they check individual units, however, they are only toggling the visibility of that specific unit.

    Can the treeview control be configured to do this?
  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 02 Sep 2010 Link to this post

    Hello Adrian de Freitas,

    The RadTreeView doesn't implement this scenario out-of-the-box. You will need to manually change the  CheckState of each item accordingly to your needs.

    Also, I am not sure if I understand your scenario completely. It seems to me as though you need to expand and collapse the Items instead of show/hide them? Is that the case or am I missing something? Can you please elaborate a bit more?

    Because if you need to check an item and expand all its sub Items thus displaying them, you can handle the Checked() and Unchecked() events:
    private void myTreeView_Checked(object sender, Telerik.Windows.RadRoutedEventArgs e)
        RadTreeViewItem checkedItem = e.Source as RadTreeViewItem;
        if (checkedItem.Level == 0)
    private void myTreeView_Unchecked(object sender, Telerik.Windows.RadRoutedEventArgs e)
        RadTreeViewItem checkedItem = e.Source as RadTreeViewItem;
        if (checkedItem.Level == 0)
            checkedItem.IsExpanded = false;

    Sincerely yours,
    Tina Stancheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top