Expand Node on SelectedItem

3 posts, 0 answers
  1. Dmitrijs
    Dmitrijs avatar
    11 posts
    Member since:
    Jun 2012

    Posted 12 Sep 2012 Link to this post


    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}"/>

  2. Petar Mladenov
    Petar Mladenov avatar
    3062 posts

    Posted 14 Sep 2012 Link to this post

    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.

    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.

  3. Dmitrijs
    Dmitrijs avatar
    11 posts
    Member since:
    Jun 2012

    Posted 18 Sep 2012 Link to this post

    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?
Back to Top