RadTreeViewItem loses CheckState when Virtualizing

5 posts, 0 answers
  1. Brian Nguyen
    Brian Nguyen avatar
    9 posts
    Member since:
    Sep 2009

    Posted 26 May 2010 Link to this post

    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.
  2. Brian Nguyen
    Brian Nguyen avatar
    9 posts
    Member since:
    Sep 2009

    Posted 26 May 2010 Link to this post

    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.
  3. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 26 May 2010 Link to this post

    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.
  4. Brian Nguyen
    Brian Nguyen avatar
    9 posts
    Member since:
    Sep 2009

    Posted 26 May 2010 Link to this post

    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.
  5. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 27 May 2010 Link to this post

    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.
Back to Top