Change SelectedTreeItem to collapsed item

Hi,
When I change SelectedLevel in view model to one of collapsed tree items nothing happens. I would like to have this item expanded and brought into view automatically. Example of my view:

<sf:TreeViewAdv ItemsSource="{Binding Levels}" SelectedTreeItem="{Binding SelectedLevel}" />

If I expand the nodes manually all works fine then.

Thank you for your help!

Regards

Ondřej Svoboda

3 Replies

VR Vijayalakshmi Roopkumar Syncfusion Team February 5, 2018 10:59 AM UTC

Hi Ondrej

Thank you for contacting Syncfusion Support.

From your query, we understood that your requirement is to expand the Selected TreeViewItemAdv. If it is your requirement, it can be achieve using the IsExpanded property. The same has been explained in the following KB article.

KB link: http://www.syncfusion.com/kb/3390/how-to-expand-selected-treeviewitemadv-on-button-click 

Please let us know if you need further assistance on this.

Regards
Vijayalakshmi V.R. 



OS Ondrej Svoboda February 20, 2018 02:43 PM UTC

Hi, thank you for your help.
Now I'm able to expand and select bound items using TreeViewItemAdv's IsExpanded and IsSelected properties.
The last think which is not working to me is how to bring selected item into view if it is a long list of items. I've seen TreeViewAdv.BringIntoView method but I cant use it because my items are not TreeViewItemAdv - I'm using bound model like in your example.

Regards
Ondřej Svoboda


KJ Keerthana Jegannathan Syncfusion Team February 21, 2018 09:19 AM UTC

Hi Ondrej, 
 
Thanks for your update. 
 
In TreeViewAdv, we were to unable to retrieve the item of type “TreeViewItemAdv” as we are using HierarchicalDataTemplate when binding has been made. Therefore, it is not possible to bring the item in to the view as item has been retrieved based on the control used inside the HierarchicalDataTemplate. Please let us know if you need further assistance on this. 
 
Regards, 
Keerthana J 


Loader.
Up arrow icon