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

ExpandAllHierarchyItems() doesn't work

6 Answers 139 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Bin
Top achievements
Rank 1
Bin asked on 12 Jan 2012, 08:55 PM
Hi,

I'm using 2011 Q1 version of RadTreeListView to show some hierarchical data. The data only have two layer: parent level category, under each category, there are some data errors:

In xaml:
...

<UserConrol.DataContext>

    <viewmodel:DataErrorsViewModel x:Name="Data" />

</UserConrol.DataContext>

...

<

telerik:RadTreeListView x:Name="TreeListView" ItemsSource="{Binding DataErrors, Mode=TwoWay}" DataLoaded="TreeListView_DataLoaded">
...

</telerik:RadTreeListView>


In Code-Behind:
...
private
void TreeListView_DataLoaded(object sender, System.EventArgs e)  

{

    TreeListView.DataLoaded -= TreeListView_DataLoaded;

    TreeListView.ExpandAllHierarchyItems();

}

The ItemsSource(DataErrors) is populated by a view model class. The above code only works when I populate some dummy data. But when I call a service method asynchronously to populate the ItemsSource, the above code doesn't work because when the event handler is called, the asynchronous call hasn't been finished yet so there is nothing in the ItemsSource.

Is there any other way to do this? Please Help. 

6 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 13 Jan 2012, 12:18 PM
Hello,

When the data is loaded asynchronously, you could expand each row on RadGridView's RowLoaded event, or alternatively, to invoke ExpandAllHierarchyItems after all the elements have been added to the visual tree.

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Bin
Top achievements
Rank 1
answered on 13 Jan 2012, 03:52 PM
Hi Didie,

Thank you for your reply. Would you mind giving me some sample code?

Thanks,
Bin
0
Dimitrina
Telerik team
answered on 13 Jan 2012, 04:00 PM
Hello,

 Actually, you can try setting the AutoExpandItems property of the RadTreeListView to True. That way the hierarchy items should be expanded once the data is loaded.

<telerik:RadTreeListView AutoExpandItems="True"/>

Does this do the trick?
 

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Bin
Top achievements
Rank 1
answered on 13 Jan 2012, 04:17 PM

Hi Didie,

AutoExpendItems property is not available for me (The Property 'AutoExpandItems was not found in type 'RadTreeListView'.)

I'm using Q1 2011 SP1 version of Rad Controls and I reference telerik in XAML by

xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"

Any idea?

 

0
Dimitrina
Telerik team
answered on 13 Jan 2012, 04:43 PM
Hello,

 Then you could try to set the ItemsSource of the TreeListView in the completed event of the Service. Then call the ExpandAllHierarchyItems() method.

Please let me know how this works.


Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Bin
Top achievements
Rank 1
answered on 13 Jan 2012, 05:18 PM
Didie,

It works but it's agaisnt the MVVM principle. I have to reference the view within the view model and set the UI behavior in the view model.

For now it's good enough. I just wish I could do it in XAML.

Thanks for your help!
Bin

Tags
TreeListView
Asked by
Bin
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Bin
Top achievements
Rank 1
Share this question
or