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
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.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thank you for your reply. Would you mind giving me some sample code?
Thanks,
Bin
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 >>
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?
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.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
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