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

Dropdown button and Tree view

1 Answer 78 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
FlR
Top achievements
Rank 2
FlR asked on 20 Dec 2011, 01:17 PM
We have implemented the tree view inside a buttonwood as it is specified here:
http://blogs.telerik.com/valerihristov/posts/10-05-12/treeview-in-combobox-with-radcontrols-for-silverlight-or-wpf-final-take.aspx

The question I have is how can we preselect externally (by clicking another button) an item and appear selected in the dropdown.

We have tried with:
trViewDates.ExpandItemByPath(........., "|");
trViewDates.ContainerFromItemRecursive(..............).IsSelected = true;

but this will not work as the trViewDates.ContainerFromItemRecursive(..............). returns null if the dropdown is not selected and opened.

In our case we want to preselect from an external control event.

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 23 Dec 2011, 02:24 PM
Hi,

 Do you need only selection to be made or you need selection + bringing the item in the viewport ?
If you need just selection without viewing the selected items, you can use ViewModels, introduce boolean property in the ViewModel and bind it to the IsSelected property of the RadTreeViewItems via ContainerBindings
The ContainerFromItemRecursive method returns the visual Container ( the RadTreeViewItem that contains info about your business object/ item/ ViewModel). It will return null in all scenarios in which the container is not yet generated. If the dropdown button has never been opened, the RadTreeView has never been loaded and no RadTreeviewItems have been generated.
 So I suggest you to first open the DropDownButton and then use the BringPathIntoView method, which will bring a desired item into view event if it hasn't been prepared yet (it will be prepared since  its parent containers will be expanded by the method's logic).

Regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
ComboBox
Asked by
FlR
Top achievements
Rank 2
Answers by
Petar Mladenov
Telerik team
Share this question
or