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

Checking Child Items

1 Answer 40 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 28 Aug 2011, 09:52 PM
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?

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 31 Aug 2011, 03:39 PM
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 >>

Tags
TreeView
Asked by
Paul
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or