TreeView in ComboBox select item in code

5 posts, 1 answers
  1. Peter Meinl
    Peter Meinl avatar
    35 posts
    Member since:
    Jan 2010

    Posted 03 Mar 2010 Link to this post

    I am using the TreeView in ComboBox from Valeri
    http://blogs.telerik.com/valerihristov/posts/09-08-27/treeview_in_combobox_take_3_silverlight_3_wpf_and_radcontrols.aspx

    How can I set the selected item programmatically?

    I tried
    myTreeViewCombo.SelectedTreeViewItem = someItem
    and
    myTreeViewCombo.SelectedValue = someItem

    The item seems to get selected, but the selection does not display in the ComboBox.
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 03 Mar 2010 Link to this post

    Hello Peter,

    RadTreeView cannot automatically select items by setting its SelectedItem/Value properties. To select an item you should find it and set its IsSelected property to true.

    Greetings,
    Valeri Hristov
    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Peter Meinl
    Peter Meinl avatar
    35 posts
    Member since:
    Jan 2010

    Posted 03 Mar 2010 Link to this post

    How can I reference the TreeView inside the TreeViewComboBox from code?
  5. Answer
    Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 04 Mar 2010 Link to this post

    Hi Peter,

    I guess that it would be easier if you put RadTreeView inside a RadDropDownButton:
    http://demos.telerik.com/wpf/?Buttons/DropDownButton

    This way you will be able to directly reference the TreeView and use it as it is on the page.

    Sincerely yours,
    Valeri Hristov
    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.
  6. Peter Meinl
    Peter Meinl avatar
    35 posts
    Member since:
    Jan 2010

    Posted 04 Mar 2010 Link to this post

    Thank you for this good suggestion.

    However, with a TreeView in DropDownButton I did not know, how to find the DropDownButton the TreeView belongs too on TreeView.SelectionChanged (I create many DropDownButtons dynamically in code).

    Thus I gave up on trees and use 2 ComboBoxes instead.
Back to Top
UI for WPF is Visual Studio 2017 Ready