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

When to call ExpandAll()

4 Answers 138 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
cecilUOA
Top achievements
Rank 1
cecilUOA asked on 20 Nov 2009, 02:37 AM
I would like my tree to be fully expanded by default. So I am looking for a place to put RadTreeListView1.ExpandAll().
So far I have tested
  • GotFocus - which doesnt get called automatically. 
  • ItemPrepared - which get called on every item in the tree, but expandAll() doesnt expand the first node (the root node). The rest of the tree does fully expanded once I manually expand the root node.
  • Loaded - which fires when the tree control is loaded, not its data.

I think I understand why ExpandAll() wasnt working for the root node. The tree control binds to just the root node as its ItemsSource. 

In xmal...

 

ItemsSource="{Binding TreeListItemsSource}"  

 

 

In ViewModel...  

public ObservableCollection<HierarchicalData> TreeListItemsSource { getset; }  

 

And the TreeListItemsSource only has the root node. The rest of the tree is linked by Items property in each HierarchicalData object.

 

 

 

 

 

 

 

 

 

 

4 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 24 Nov 2009, 12:29 PM
Hi Doug,

You can define an ItemContainerStyle and add a setter for the IsExpanded property.

<Style TargetType="telerikNavigation:RadTreeListViewItem">
    <Setter Property="IsExpanded" Value="True" />
</Style>

This way, as soon as the RadTreeListView loads, all of its items will be expanded. Give it a try and let me know how it works for you.

Greetings,
Kiril Stanoev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
cecilUOA
Top achievements
Rank 1
answered on 24 Nov 2009, 08:49 PM
Thanks for the suggestion.

However it's still not working. Maybe when RadTreeListView is loaded, the data that it binds to hasnt arrived yet?

Just to be doubly sure, I should be putting that code inside UserControl.Resources, yes?
0
Accepted
Kiril Stanoev
Telerik team
answered on 25 Nov 2009, 05:14 PM
Hello Doug,

You can put the ItemContainerStyle either in the UserControl.Resources:

<UserControl.Resources>
    <Style x:Key="TreeListItemStyle" TargetType="telerikNavigation:RadTreeListViewItem">
        <Setter Property="IsExpanded" Value="True" />
    </Style>
</UserControl.Resources>
  
<Grid x:Name="LayoutRoot">
    <telerikNavigation:RadTreeListView ItemContainerStyle="{StaticResource TreeListItemStyle}" />
</Grid>

Or you can put it inline with RadTreeListView's definition:

<Grid x:Name="LayoutRoot">
    <telerikNavigation:RadTreeListView>
        <telerikNavigation:RadTreeListView.ItemContainerStyle>
            <Style TargetType="telerikNavigation:RadTreeListViewItem">
                <Setter Property="IsExpanded" Value="True" />
            </Style>
        </telerikNavigation:RadTreeListView.ItemContainerStyle>
    </telerikNavigation:RadTreeListView>
</Grid>

However, it is strange that that you are experiencing this issue.
I am attaching the source code of RadTreeListView's FirstLook example. It demonstrates the IsExpanded functionality. Have a look at it and if you have additonal questions or you find something to be unclear, let me know as soon as possible. I'd be more than happy to assist you.

Greetings,
Kiril Stanoev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
cecilUOA
Top achievements
Rank 1
answered on 25 Nov 2009, 10:13 PM
I tried having ItemContainerStyle in the UserControl.Resources and reference in my treeListView, and it works. Thank you very much for the help.
Tags
TreeListView
Asked by
cecilUOA
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
cecilUOA
Top achievements
Rank 1
Share this question
or