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

RadTreeViewItem loses CheckState when Virtualizing

4 Answers 73 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Brian Nguyen
Top achievements
Rank 1
Brian Nguyen asked on 26 May 2010, 05:24 PM
I have a RadTreeView in TriStateMode with IsVirtualized="True". If I check some items and scroll them out of view, the CheckState reverts back to off.

It seems that the RadTreeViewItems are being recycled and when recreated, the CheckState is lost. I have implemented ContainerBindings in a OneWay mode so that when the RadTreeViewItems are recreated they will bind to the current value of my underlying model (that contains an IsChecked property). However, this is not working. I would appreciate any help on this behavior.

4 Answers, 1 is accepted

Sort by
0
Brian Nguyen
Top achievements
Rank 1
answered on 26 May 2010, 05:59 PM
I was able to implement a work-around. Instead of using container bindings, I subscribed to the ItemPrepared event and set the RadTreeViewItem's CheckState to the current value of my model's IsChecked property.
0
Miroslav
Telerik team
answered on 26 May 2010, 06:15 PM
Hello Brian Nguyen,

Which version of the controls are you using? We are not aware of an issue with the container bindings. If they do not work this will be a bug.

I can suggest using two-way bindings since one-way bindings are reset when the target value (the item's checkState) changes. It is possible that your bindings will be lost when the user changes the CheckState.

I tried this with the 2010.1.0422 version and it works as expected on my side, you can find the project attached.

Kind regards,
Miroslav
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.
0
Brian Nguyen
Top achievements
Rank 1
answered on 26 May 2010, 07:41 PM
Using TwoWay ContainerBindings on the CheckState property fixed the issue of it losing the CheckState when scrolled out of view. However, if the children of the parent RadTreeViewItem is expanded and some children are out of view, those children are not checked when the parent RadTreeViewItem is checked.
0
Miroslav
Telerik team
answered on 27 May 2010, 08:00 AM
Hello Brian Nguyen,

When the TreeView is virtualized it only keeps enough items to display the contents of the Viewport. The TreeView in fact delays the checking of these items and you should find them in the CheckedItems collection on the TreeView.

If the CheckedState is not databound, the TreeView will make sure that the items outside the Viewport are update once they are recreated.

When there is databinding though, it takes precedence over the value we think should be assigned. Then it is expected that the ViewModel will provide the correct value and it should not be overriden. This is necessary in the cases where the checked value changes when the items are outside the Viewport and we have no notification of the event.

I can suggest updating the checked state of your child items in code once you receive a notification that a parent has been checked.

Greetings,
Miroslav
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.
Tags
TreeView
Asked by
Brian Nguyen
Top achievements
Rank 1
Answers by
Brian Nguyen
Top achievements
Rank 1
Miroslav
Telerik team
Share this question
or