This is a migrated thread and some comments may be shown as answers.

Expand Node on SelectedItem

2 Answers 201 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Dmitrijs
Top achievements
Rank 1
Dmitrijs asked on 12 Sep 2012, 10:59 AM
HI,

I have a problem. I have AutoCompleteTextBox and TreeView, both work with the same SelectedItem.
The node must expand, when the user uses AutoCompleteTextBox, but it only works only if I expand node per MouseClick and Collapse it.

   <telerik:RadTreeView Grid.Row="1" Grid.ColumnSpan="3"
                                             IsEnabled="{Binding DisableOnEditMode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                             ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                             SelectedItem="{Binding SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                            <telerik:RadTreeViewItem IsExpanded="True"  Header="Nachschlagstabellenliste" Style="{StaticResource HeaderItem}" >
                                <telerik:RadTreeViewItem  Header="Dokumenttyp"
                                                     ItemTemplate="{StaticResource LookupItemTemplate}" Style="{StaticResource SubHeaderItem}"
                                                     ItemsSource="{Binding DocumentTypes, UpdateSourceTrigger=PropertyChanged}"/>
 
                                <telerik:RadTreeViewItem  Header="Dokumentart"
                                                     ItemTemplate="{StaticResource LookupItemTemplate}" Style="{StaticResource SubHeaderItem}"
                                                     ItemsSource="{Binding DocumentSysTypes, UpdateSourceTrigger=PropertyChanged}"/>
...

Thanks!

2 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 14 Sep 2012, 08:21 AM
Hello Dmitrijs,

I am not quite sure how you implement this requirement but you have to know that the RadTreeViewItems are generated when their parent is expanded or when they are root level items. In other words, you may have come up with a situation in which you try to expand an item that is not prepared yet.
However, I strongly suggest you to look at our OrgChart demo demonstrating similar functionality. Expand the Blue Button on the Right. When you choose a person from the RadComboBox, it's corresponding item from the RadTreeView is being brought into view. The method used in the RadTreeView is BringPathIntoView() which is ready to bring a not-prepared RadTreeViewItems. It actually forces the generation of items in the ItemContainerGenerator of the RadTreeView. Please find its documentation article here.

Regards,
Petar Mladenov
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Dmitrijs
Top achievements
Rank 1
answered on 18 Sep 2012, 10:22 AM
Thanks for reply, but I didnt get how to expand a node from source.
If I use selectionchanged event => e.AddedItems[0] -> its an object and not a treeviewitem.
How can i get selected treeviewitem?
Tags
TreeView
Asked by
Dmitrijs
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Dmitrijs
Top achievements
Rank 1
Share this question
or