How do I force binding before display on RadDropDownButton with Treeview?

2 posts, 0 answers
  1. Todd Davis
    Todd Davis avatar
    36 posts
    Member since:
    Aug 2009

    Posted 06 Apr 2010 Link to this post

    Here is the situation. I have a RadDropDownButton, which uses a RadTreeView as its DropDownContent. The RadTreeView is setup to use Checkboxes, and those CheckBoxes are bound to the data objects as described in the documentation. (In other words, the data object has a bool called IsChecked, and the Checkbox is bound to that)

    All of this works just fine, generally speaking.

    The problem I'm having is that when I initially bind the TreeView, I need to get an accurate count of how many Checkboxes are selected.

    This is causing a problem for me however, as the CheckBoxes don't actually bind until I click the RadDropDownButton and display the TreeView. At that point, the TreeView "kicks in" and everything binds. Prior to that, the Treeview. CheckedItems.Count == 0

    How can I force the TreeView to complete the binding and give me an accurate CheckedItems.Count() without requiring the user to click the dropdown for that to happen?

  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 09 Apr 2010 Link to this post

    Hello Todd Davis,

    The RadTreeView CheckedItems collection is populated after the TreeView items containers are generated. The items containers are generated when the RadTreeView is loaded, therefore you cannot get the number of the checked items before the RadTreeView is loaded.

    However, in your case you can use ContainerBindings with TwoWay Mode binding, like this:
    <telerik:ContainerBindingCollection x:Name="BindingsCollection">
                <telerik:ContainerBinding PropertyName="CheckState"
                                          Binding="{Binding IsChecked, Mode=TwoWay,
                                                    Converter={StaticResource CheckStateConverter}}"/>

    And then you can search through the ItemsSource collection of the RadTreeView and count the checked items.

    I prepared an example for you to take a look at. I hope this works for you.

    Let me know if I can further assist you.

    Best wishes,
    Tina Stancheva
    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