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

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

1 Answer 82 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
Todd Davis
Top achievements
Rank 1
Todd Davis asked on 06 Apr 2010, 08:24 PM
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?


1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 09 Apr 2010, 02:45 PM
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}}"/>
</telerik:ContainerBindingCollection>


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.
Tags
Buttons
Asked by
Todd Davis
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or