Expand Treeview and select Item

9 posts, 1 answers
  1. Ryan Black
    Ryan Black avatar
    54 posts
    Member since:
    Mar 2010

    Posted 18 Nov 2010 Link to this post

    I have been having trouble selecting a treeview item that is located a few nodes deep.

    You can see my example here: File Expand and Select

    To get the example working, please copy the foo folder to c:\foo.

    Thanks for all your help
    Ryan
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 23 Nov 2010 Link to this post

    Hello Ryan Black,

    I examined your project and did not manage to understand your issue. Pressing  the button adds a new file in the second tree level (level with root "GG") and selects it. On the other hand, selecting a node that is located several levels deep works just fine. Could please elaborate more on the scenario that shows the problem best ? If you can please list the steps to reproduce the issue and/or send us a video illustrating the behavior on your side, that will also help us further investigate the issue.

    Thank you for the cooperation in advance.

    Best wishes,
    Petar Mladenov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ryan Black
    Ryan Black avatar
    54 posts
    Member since:
    Mar 2010

    Posted 23 Nov 2010 Link to this post

    Heres the problem.

    If you click Add text file, and you have nothing expanded, the folders needs to expand and show the item selected.  The bug is that currently the folders are not expanding all the way down to the treeview item that I want selected.

    Hope this is a little more clear.

    Ryan
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 26 Nov 2010 Link to this post

    Hi Ryan Black,

    We modified the solution in order to work for you. Basically, in the second method ExpandAndSelectItem(ItemsControl itemsControl, object itemToSelect)  you are trying to use RadTreeViewItem that is not generated. You can generate it by expanding his father in ExpandAndSelectItem(object itemToSelect) .
    However, I highly recommend you to use ExpandItemByPath and GetItemByPath methods in order to achieve the desired effect.

    Hope this has helped you and you`ll feel free to ask if you need further assistance.

    Greetings,
    Petar Mladenov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  6. Ryan Black
    Ryan Black avatar
    54 posts
    Member since:
    Mar 2010

    Posted 30 Nov 2010 Link to this post

    Petar,

    Thanks for all your help.  I want to always use best practices with these controls and have tried to implement ExpandItemByPath and GetItemByPath .  I followed some examples and seem to be missing something.

    Could you please look at my modified FileExplorerExample and see what I have missed.

    Thanks
    Ryan

    File Explorer Example
  7. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 03 Dec 2010 Link to this post

    Hello Ryan Black,

    It seems that you are trying to expand an item in your outer tree( "fileExplorer" ) instead of your inner tree ("foldertree"). On the other hand, you must specify the property of your business object that GetItemByPath and ExpandItemByPath methods use in their search algorithms:
    <telerik:RadTreeView IsExpandOnSingleClickEnabled="True" telerik:TextSearch.TextPath="Name"/>
    I modified your solution accordingly. Please examine it and let me know if it works for you. Also, please keep in mind that since you have nested RadTreeViews, you should be careful which RadTreeView's features you need to use at a certain point. Also, I am not sure why your scenario requires using nested RadTreeViews, but if your logic can be implemented with just one RadTreeView, it would simplify your code.

    Regards,
    Petar Mladenov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  8. Ryan Black
    Ryan Black avatar
    54 posts
    Member since:
    Mar 2010

    Posted 03 Dec 2010 Link to this post

    Petar,

    That works perfectly and the double RadTreeView was done by accident.  However, I believe there is one fundamental thing I am not understanding correctly between Telerik controls and WPF. 

    I modified the example to open another window that should auto expand and select the item in the list.  I thought the problem was with the ItemContainerGenerator.Status, but it seems that is only part of the issue.

    In our real application this type of scenario is very common, and I think this final example will solve a lot of our future potential issues.

    Thanks for all your continued help!

    Ryan

    File Explorer Example
  9. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 08 Dec 2010 Link to this post

    Hi Ryan Black,

    You can use the Loaded event of the Window that shows when you click the button instead of the ItemContainerGenerator.StatusChanged. Also, you need to use the RadTreeView that is inside the "fileExplorer" again ( you can access it via the RadTreeView.ChildrenOfType<RadTreeView>() method ). Please notice that the containers are generated only when they are needed ( in your case when you expand an item that contains child RadTreeVieItems) so StatusChanged doesn`t help you. Please inspect the attached solution and let us know if it satisfies you or not. 

    Greetings,
    Petar Mladenov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  10. Ryan Black
    Ryan Black avatar
    54 posts
    Member since:
    Mar 2010

    Posted 08 Dec 2010 Link to this post

    Thats exactly what I was looking for.  These examples have greatly allowed us to resolve many issues.  
    Thank you so much for all of you support.

    Ryan
Back to Top
UI for WPF is Visual Studio 2017 Ready