Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I have used hierarchical data template in tree view to get nodes dynamically and the tree has three level means one node can be expanded till three levels like-
-root1
..-child1
....subchild11
....subchild12

-root2
..-child2
....subchild21
....subchild22
.....
.....

and so on. My requirement is to expand the roots but to collapse the immediate children-like
-root1
..+child1
-root2
..+child2


the code that I am using is-
XML
<telerik:RadTreeView ItemsSource="{Binding Path=OrderedProductsByRun}" ItemTemplate="{StaticResource OrderedProductsByRun}" Height="300" ScrollViewer.VerticalScrollBarVisibility="Auto"
                                         ExpanderStyle="{StaticResource ExpandCollapseToggleStyle}" TabIndex="6" IsSingleExpandPath="True">
                            <telerik:RadTreeView.ItemContainerStyle>
                                <Style>
                                    <Setter Property="telerik:RadTreeViewItem.IsExpanded" Value="True"/>
                                </Style>
                            </telerik:RadTreeView.ItemContainerStyle>
                        </telerik:RadTreeView>
<HierarchicalDataTemplate 
      x:Key="OrderedProductsByRun"
      ItemsSource="{Binding Path=RoutesForRun}"
      ItemTemplate="{StaticResource RoutesForRun}"
      >
     <Stackpanel.........></Stackpanel>
<Stackpanel.........></Stackpanel>
<Stackpanel.........></Stackpanel>

</HierarchicalDataTemplate>
<HierarchicalDataTemplate 
      x:Key="RoutesForRun"
      ItemsSource="{Binding Path=OrderActivityDetails}"
      ItemTemplate="{StaticResource OrderActivityDetails}" 
      >
<Stackpanel.........></Stackpanel>
<Stackpanel.........></Stackpanel>
<Stackpanel.........></Stackpanel>
</HierarchicalDataTemplate>


                        <DataTemplate x:Key="OrderActivityDetails">
<Stackpanel.........></Stackpanel>
<Stackpanel.........></Stackpanel>
<Stackpanel.........></Stackpanel>

                        </DataTemplate>
Posted
Updated 6-Jun-12 19:54pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900