TreeView in a ComboBox

25 posts, 1 answers
  1. Rogério
    Rogério avatar
    33 posts
    Member since:
    Feb 2009

    Posted 02 Apr 2009 Link to this post

    Hello,

    I'd like to use some kind of TreeView in a ComboBox.
    I already checked post TreeView in a ComboBox dropdown using RadControls for Silverlight
    but the sample application does not work with Q1 2009 controls!

    Could you help me on some kind of solution for my problem?

    Thanks.

    Regards,
    Rogério
  2. Answer
    Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 03 Apr 2009 Link to this post

    Hello Rogério,

    I am attaching an updated version of the example. I simplified the code a bit and tested it against the latest version of the control. Let me know if you have any problems with it.

    Best wishes,
    Tihomir Petkov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. Rogério
    Rogério avatar
    33 posts
    Member since:
    Feb 2009

    Posted 03 Apr 2009 Link to this post

    Hello,

    It seams to work well.

    Thanks.

    Regards,
    Rogério
  5. NS
    NS avatar
    179 posts
    Member since:
    Jan 2007

    Posted 28 Apr 2009 Link to this post

    Hi,
    Do you have an example how this can be done trough codebehind completely ?
    My Hierarchicaldatatemplate, radcombobox and radtreeview are declared in XAML, but I would like to know how to databind a List that is filled trough an async call in codebehind to the radcombobox and radtreeview.

    Thanks,
    Nicolas
  6. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 28 Apr 2009 Link to this post

    Hi Nicolas,

    In the example the ItemsSource is set in Xaml, but that just helps the Design time. In fact, you can leave everything as it is and just set the ItemsSource whenever you have it, like after an async call to a web service.

    You may also have to change the DataTemplates so that they will bind to the correct properties of your ViewModels (the items  that you will be in the ItemsSource collection).

    Otherwise, there is no need to recreate all this in codebehind.

    Regards,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. yelong
    yelong avatar
    28 posts
    Member since:
    Aug 2006

    Posted 04 Jun 2009 Link to this post

    When testing the sample code, if I re-click the last clicked item in RadTreeView, it will give me a wrong selecteitem. Looks it returns all expanded items in the treeview.

    Could you please help to check it?

    I also want to know why it fires RadComboBox's SelectionChanged event when just changing the selecteditem in RadTreeView.

    Thanks,

    Yelong


  8. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 05 Jun 2009 Link to this post

    Hello Yelong,

    I suppose you are talking about the sample in my blog post, mentioned in the first message in this thread.

    RadComboBox.SelectionChanged event is fired every time the control selection changes. The attached behavior ComboBoxExtensions sets the SelectedItem property of RadComboBox every time the SelectedItem of RadTreeView is changed, hence the SelectionChanged event is raised.

    I was unable to reproduce the problem with the wrong selection of the treeview, could you provide more details about it?

    Regards,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. yelong
    yelong avatar
    28 posts
    Member since:
    Aug 2006

    Posted 05 Jun 2009 Link to this post

    Hi Valeri,

    Thanks for your reply. 

    it is the  screen capture .

    Yelong
  10. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 08 Jun 2009 Link to this post

    Hi Yelong,

    I am afraid that the link you provided is wrong. Could you please, open a new support ticket and attach a simple application that demonstrates the problem? You may also attach the screenshot there.

    All the best,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  11. yelong
    yelong avatar
    28 posts
    Member since:
    Aug 2006

    Posted 08 Jun 2009 Link to this post

    Sorry, I provided a wrong live. Please check this.

    http://cid-4074ce3c69ce2d01.skydrive.live.com/self.aspx/.Public/1.zip

    The application I used is just the sample you provide here.

    Thanks

    Yelong
  12. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 11 Jun 2009 Link to this post

    Hi yelong,

    Is there any chance that you are using the first approach described in my blog post? If you use the second one, that changes the control template of RadComboBox you will get the proper behavior.

    Best wishes,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  13. yelong
    yelong avatar
    28 posts
    Member since:
    Aug 2006

    Posted 11 Jun 2009 Link to this post


    I just re-download the sample from the link above. It still works as what I described. Maybe the link is not correct.

    But as the sample demonstrates, I implement the feature in my app with no problem.

    Thank you very much.

    Yelong
  14. Alan
    Alan avatar
    47 posts
    Member since:
    Jun 2009

    Posted 29 Jun 2009 Link to this post

    I just downloaded the sample from this post and I am seeing the same behavior as yelong.

    On the second combobox, if I click on the same sub-item twice in a row, the selected item shows all items in the tree.  Is there a fix for this?
  15. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 06 Jul 2009 Link to this post

    Hi Alan,

    Strange... My example application contains only one combobox. Am I missing something?

    I attached the ZIP file that is attached to the blog post, is it the same as the one you downloaded?

    Best wishes,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  16. Alan
    Alan avatar
    47 posts
    Member since:
    Jun 2009

    Posted 06 Jul 2009 Link to this post

    Valeri,

    I downloaded the example posted in this forum (treeincombo-updated.zip), by Tihomir, and it has two combo boxes.  The first showing the standard behavior, and the second showing the tree-view inside the combo box.

    However, I just downloaded your sample and I'm getting similar behavior.  Just perform the following steps:

    1) Run your sample
    2) Select the combo box drop down (don't select a parent item)
    3) Click the tree expander to expand one parent
    4) Select a child element

    No item appears in the drop down. 

    In your example, once one parent is selected, then it seems you can select a child element on the next subsequent selection.  However, if a child is already selected in the combo box, it prevents you from changing the selection to a different child.

    Tihomir's example has a different issue in that selection a child shows all elements in the tree (see Yelong's screenshot).
  17. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 06 Aug 2009 Link to this post

    Hello Alan,

    I will create a new blog post about putting TreeView into ComboBox right after the service pack release next week. I want to use the latest and greatest Silverlight 3 version of the controls, that will introduce some changes in the XAML organization in the control assemblies, hence the delay.

    Greetings,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  18. Vadim Dmitriev
    Vadim Dmitriev avatar
    1 posts
    Member since:
    Sep 2009

    Posted 26 Sep 2009 Link to this post

    Hello,

    Updated example posted by Tihomir Petkov in April works fine with Q1 but seems doesn't work any more wirh Q2 2009.
    Tree view is being dropped down nicely but selection never appears in Combo selection box.
    I tried to set combobox explicitly, bind combo text using converter, bind combo selected item and  set selected item.
    I also tried to use combo SelectionBoxItemTemplate.

    Could you please help me with this?

    Thank you
    Vadim
  19. Nikolay
    Admin
    Nikolay avatar
    3997 posts

    Posted 01 Oct 2009 Link to this post

    Hi Vadim Dmitriev,

    Thanks for your report. We actually introduced some changes in the RadComboBox control and we will have to properly update the example to address these changes. Once we do this, we will follow up with you.

    All the best,
    Nick
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  20. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 05 Oct 2009 Link to this post

    Hello Vadim,

    Please, check my blog post for more information:
    http://blogs.telerik.com/blogs/posts/09-08-27/treeview_in_combobox_take_3_silverlight_3_wpf_and_radcontrols.aspx

    I think that I have somewhere an example for setting the selection in RadTreeView, let me know if you need it.

    Greetings,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  21. iramz
    iramz avatar
    23 posts
    Member since:
    Jan 2010

    Posted 09 Feb 2010 Link to this post

    hello hristov,

    i downloaded the sample from the link above.got it working! i just want to ask about he hard coded theme (office black). i removed it but somehow, the ScrollViewer wont get my application's theme. but the PickerToggleButton can.sorry if out of topic.
  22. Kiran Ghanwat
    Kiran Ghanwat avatar
    38 posts
    Member since:
    Nov 2009

    Posted 10 May 2010 Link to this post

    Hello,
    Valeri Hristov

        I have checked your latest example, it working alright.
        You have used Binaries version 2009.1.312.1020. And I am using 2010.1.422.1030
        
        Because, of this when I selects child item e.g. child 1.3 from treeview. that, does loads as "SelectedItem" in the combobox.
        but, Child item e.g. child 1 gets loaded in the combobox.
        
        but, in case of your example all works alright.
        
    Please help.

    Thanks,
    Kiran Ghanwat
  23. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 12 May 2010 Link to this post

    I would recommend using the new and much simpler approach to the problem, demonstrated in the following blog post:
    http://blogs.telerik.com/valerihristov/posts/10-05-12/treeview_in_combobox_with_radcontrols_for_silverlight_or_wpf_final_take.aspx

    Regards,
    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.
  24. Ryan Lege
    Ryan Lege avatar
    42 posts
    Member since:
    Sep 2008

    Posted 14 May 2010 Link to this post

    I've tried this and I'm using 2010. The Template will not bind to the Combobox. It could be that the Combobox resides in a custom Appointment form I use for Rad Scheduler Silverlight. Anybody please help!!!!
  25. Marcos
    Marcos avatar
    5 posts
    Member since:
    Jul 2012

    Posted 04 Jun 2013 Link to this post

    Hi,

    I'm using RadControls for Silverlght version 2012.2.912.1050 but when I select one item from the RadTreeView a blurred text is shown in the RadComboBox, could someone give some help?

    I have the entire solution ported to Visual Studio 2012 and SL 5 at http://sdrv.ms/ZM9oKw

    Thank you very much
    Marcos
  26. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 07 Jun 2013 Link to this post

    Hi,

    By design placing a TreeView control as an ItemsSource to the ComboBox control is not a built-in and supported feature and there maybe some issues. We noticed that in the uploaded project you have directly placed the TreeView control inside the RadComboBox control. As the blog post mentions:

    This works, but it has one important limitation: RadComboBox cannot display the RadTreeView selected item.

    The blog post describes an approach with the creation of ComboBoxExtensions and attached properties in order to make the selection of the TreeView control to be added as selection to the ComboBox. Hope this information is helpful.

    Regards,
    Vladi
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner