Dropdown button and Tree view

2 posts, 0 answers
  1. FlR
    FlR avatar
    8 posts
    Member since:
    Oct 2010

    Posted 20 Dec 2011 Link to this post

    We have implemented the tree view inside a buttonwood as it is specified here:

    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.
  2. Petar Mladenov
    Petar Mladenov avatar
    2882 posts

    Posted 23 Dec 2011 Link to this post


     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).

    Petar Mladenov
    the Telerik team

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

  3. DevCraft banner
Back to Top