Checking Child Items

2 posts, 0 answers
  1. Paul
    Paul avatar
    38 posts
    Member since:
    Oct 2008

    Posted 28 Aug 2011 Link to this post

    I have a tree view with 3 levels, 1 parent item that has 4 child items, each child item has it's own child items. I'm trying to programmatically uncheck child items but it does not appear to work. I've tried [childitem].ischecked = false but this does not work and [childitem].checkstate will only work if the child item has been expanded.

    Is there any way to programmatically set the checked state?
  2. Petar Mladenov
    Petar Mladenov avatar
    2882 posts

    Posted 31 Aug 2011 Link to this post

    Hello Paul,

    The behavior you have encountered is expected. When a RadTreeViewItem is being expanded, then the generation of its child items starts. So setting IsChecked in code behind for an unrealized item won't work.
    The best approach in such situations is to use ViewModels. In the ViewModel you can have boolean property  (or ToggleState property) that you can bind to the RadTreeViewItem's IsChecked or CheckState property via ContainerBindings. Then you can change the properties in the ViewModel dynamically and the binding will work when the items are being generated. Please let us know if you need further assistance. 

    Best wishes,
    Petar Mladenov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. DevCraft R3 2016 release webinar banner
Back to Top