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

Changing TreeListViewTableDefinition's ItemsSource

1 Answer 130 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 12 Oct 2011, 01:08 AM
Hi,

I have a typical tree list setup:

        <telerik:RadTreeListView ItemsSource="{Binding OuterList}">
            
            <telerik:RadTreeListView.ChildTableDefinitions>
                <telerik:TreeListViewTableDefinition ItemsSource="{Binding MiddleList}">
                    <telerik:TreeListViewTableDefinition.ChildTableDefinitions>
                        <telerik:TreeListViewTableDefinition ItemsSource="{Binding InnerList}"/>
                    </telerik:TreeListViewTableDefinition.ChildTableDefinitions>
                </telerik:TreeListViewTableDefinition>
            </telerik:RadTreeListView.ChildTableDefinitions>

    </telerik:RadTreeListView>

Initially, OuterList, MiddleList and InnerList were all ObservableCollections. But when I'm adding or removing 100s of items from a list, ObservableCollection fires an event for each change and a huge amount of time (minutes) gets used up in RadTreeListView, apparently figuring out the new UI layout.

So I decided to make MiddleList a List<MyObject> property. I'd calculate the new contents of MiddleList elsewhere, then I'd set the MiddleList property to the new list. Changing that property would trigger an INotifyPropertyChanged.PropertyChanged event. All the changes would become visible to RadTreeListView in a single event.

Unfortunately, RadTreeListView doesn't seem to respond to a PropertyChanged event that changes the TreeListViewTableDefinition's ItemsSource. When I set MiddleList to a new value, the list of displayed items does not change.

Is there a way to force RadTreeListView to re-load its table definitions? Is there another approach I should be taking?

Thanks,
   Bob Alexander

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 14 Oct 2011, 02:59 PM
Hello Bob,

 You could use a RadObservableCollection instead of List. This collection allows you to suspend or resume its notifications. So you could suspend your notifications when you will add or remove many items.

This will solve your problem. 

Regards,
Didie
the Telerik team

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

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