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

Binding to CheckState

9 Answers 130 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
JTango
Top achievements
Rank 1
JTango asked on 15 Jan 2009, 04:26 AM
Hi,

Is there any way to bind to the CheckState of an Item in the TreeView?

Cheers

Justin Taylor

9 Answers, 1 is accepted

Sort by
0
Tihomir Petkov
Telerik team
answered on 15 Jan 2009, 04:40 PM
Hi Justin,

Can you give me a bit more details about what you're trying to do? Do you need to bind a TreeViewItem's CheckState to a property of a binding source or you want to bind some other control to a TreeViewItem's CheckState?

Kind regards,
Tihomir Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
JTango
Top achievements
Rank 1
answered on 15 Jan 2009, 10:32 PM
The first one, I want to bind the CheckState to the underlying object.
0
Tihomir Petkov
Telerik team
answered on 16 Jan 2009, 02:11 PM
Hello Justin,

I am attaching a sample project showing how to bind the CheckState property. Basically you would want to create a custom collection of TreeViewIems which would act as a wrapper around your original data source. Let me know if you have further questions.

Kind regards,
Tihomir Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
JTango
Top achievements
Rank 1
answered on 19 Jan 2009, 05:57 AM
Thanks for the example. The problem I have is that if I check the root node without expanding it, this should check every child item, however, the binding is not updated until the tree view items are brought in to a visible state i.e. the root node is expanded.
0
Valentin.Stoychev
Telerik team
answered on 19 Jan 2009, 12:45 PM
Hello Justin,

Yes - this is the behavior of the Treeview. It is working that way because of the way the Silverlight framework is working. Before an item is visible - it is not generated from the framework - thus the binding is not applied.

What is your scenario - can we help with some custom code here?

Best wishes,
Valentin.Stoychev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
JTango
Top achievements
Rank 1
answered on 20 Jan 2009, 02:11 AM
Not sure if you can help or not. My scenario is exactly as I have described. I want to check the root node and have it check all child nodes (in the underlynig collection) regardless of whether they have been shown or not. I wouldn't think this would be too much of an uncommon scenario.

Cheers

Justin
0
Tihomir Petkov
Telerik team
answered on 21 Jan 2009, 01:26 PM
Hi Justin,

I am attaching a project showing how to listen for the Checked event and set the CheckState of the child items in the data source yourself when a parent item is checked. This way you will have the CheckState propagated in the data source before the items are actually displayed. Let me know if this solves your issue.

Greetings,
Tihomir Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
JTango
Top achievements
Rank 1
answered on 27 Oct 2009, 02:37 AM
Has anyone out there found a solution for this that actually works. I am trying to do this in WPF not Silverlight.
0
Tihomir Petkov
Telerik team
answered on 02 Nov 2009, 10:31 AM
Hi Justin,

I apologize for the delayed answer. I created a WPF version of the project, which is attached to my reply. Please take a look at it and let me know if it works for you. In your last post you ask for a solution "that actually works". What do you mean by that? Is there any problem with the first project I sent, other than the fact that it is targeting the Silverlight platform?

Sincerely yours,
Tihomir Petkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TreeView
Asked by
JTango
Top achievements
Rank 1
Answers by
Tihomir Petkov
Telerik team
JTango
Top achievements
Rank 1
Valentin.Stoychev
Telerik team
Share this question
or