Hi, I have the following RadTreeView:
I am doing a refresh of the tree using a button which recreates all the item ViewModels in the tree and then I am attempting to restore the state of the tree i.e. expand previously expanded nodes and set previously selected item. This is all done from within the tree's ViewModel.
This all works fine as long as the user has not scrolled down. Unfortunately, when the user has scrolled down and a refresh happens, the user will then only see the root nodes (not expanded) unless they scroll back up to the top of the tree.
In order to work around this I subscribed to the tree's ItemContainerGenerator.StatusChanged event after refreshing the data to check when the items are finished generating and then I used the BringItemIntoView or BringIndexIntoView methods to bring to the selected item into view.
However, this doesn't currently work due to the following exception being thrown when either of these methods are called.:
Cannot call StartAt when content generation is in progress.
Any help would be appreciated with this problem,
Thanks,
A.
<
tc:RadTreeView
x:Name
=
"tree"
ItemsSource
=
"{Binding CategoryCollectionView, UpdateSourceTrigger=PropertyChanged}"
SelectionChanged
=
"RadTreeView_SelectionChanged"
LoadOnDemand
=
"tree_LoadOnDemand"
IsVirtualizing
=
"True"
tc:TreeViewPanel.VirtualizationMode
=
"Standard"
ta:AnimationManager.IsAnimationEnabled
=
"False"
IsDragTooltipEnabled
=
"False"
IsDragDropEnabled
=
"True"
SelectionMode
=
"Multiple"
>
<
tc:RadTreeView.Resources
>
<
Style
TargetType
=
"{x:Type ScrollBar}"
/>
<
HierarchicalDataTemplate
DataType
=
"{x:Type local:CategoryTreeItemViewModel}"
ItemsSource
=
"{Binding ChildrenCollectionView}"
>
<!--snip-->
</
HierarchicalDataTemplate
>
<
DataTemplate
DataType
=
"{x:Type local:EventNodeViewModel}"
>
<!-- snip -->
</
DataTemplate
>
</
tc:RadTreeView.Resources
>
<
tc:RadTreeView.ItemContainerStyle
>
<
Style
TargetType
=
"{x:Type tc:RadTreeViewItem}"
>
<
Setter
Property
=
"IsExpanded"
Value
=
"{Binding IsExpanded, Mode=TwoWay}"
/>
<
Setter
Property
=
"IsSelected"
Value
=
"{Binding IsSelected, Mode=TwoWay}"
/>
<
Style.Triggers
>
<
DataTrigger
Binding
=
"{Binding DataContext.IsMainCategoryTree, ElementName=tree}"
Value
=
"True"
>
<
Setter
Property
=
"IsLoadOnDemandEnabled"
Value
=
"{Binding LoadOnDemand}"
/>
</
DataTrigger
>
</
Style.Triggers
>
</
Style
>
</
tc:RadTreeView.ItemContainerStyle
>
</
tc:RadTreeView
>
I am doing a refresh of the tree using a button which recreates all the item ViewModels in the tree and then I am attempting to restore the state of the tree i.e. expand previously expanded nodes and set previously selected item. This is all done from within the tree's ViewModel.
This all works fine as long as the user has not scrolled down. Unfortunately, when the user has scrolled down and a refresh happens, the user will then only see the root nodes (not expanded) unless they scroll back up to the top of the tree.
In order to work around this I subscribed to the tree's ItemContainerGenerator.StatusChanged event after refreshing the data to check when the items are finished generating and then I used the BringItemIntoView or BringIndexIntoView methods to bring to the selected item into view.
However, this doesn't currently work due to the following exception being thrown when either of these methods are called.:
Cannot call StartAt when content generation is in progress.
Any help would be appreciated with this problem,
Thanks,
A.