Hi,
we have a dataset of several thousand items which needs to be fully expanded if some search criteria is applied. This can be displayed with virtualization enabled but we encounter an issue where if we add new records the scroll position jumps to the top, this is not the case with virtualization disabled.
we are using a hierarchical data template to display our tree view items , and would like the scroll position to remain somewhat consistently in the same place.
Thanks,
Richard
Hi,
Sorry for the delay, I have attached an example solution (no .exe sorry; issues with firewall)
Example Scenario
--> Expand data
--> Scroll Down
--> Add data
Result:
Scroll position will sometime move.
Our intended use case involves supplying real time (every 10 seconds or so) updates to this treeview, and this issue reduces the usability.
Thank you for the project. The jump happens because you reset the ItemsSource of the RadTreeView control and its child items. This happens on two places in the code. The first one is the RefreshNode() call that raises PropertyChanged for the TreeItems property. And the second one is the call that sets the DataContext of the MainWindow to null and then back to "treeSearch". Both those actions reset the ItemsSource which is redrawning the RadTreeView control.
To avoid the jump, instead of resetting the ItemsSource, you can just add or remove items from the hierarchy. Note that this cannot happen with the current setup (with the Dictionary and the IValueConverter). To achieve the desired effect, you can use ObservableCollection and hierarchy-based data models. The idea here is that the collections in the hierarchy should implement the INotifyCollectionChanged in order to allow updates in the UI when an item is added or removed. I've updated your project to show one way to do this. I hope that helps.
Note that in the attached project you can still see a behavior that seems like jumping, but this is only if items are added after the current viewport. In this case, the scrollable height changes because you extend the viewport with new items.