Method SetExpandedAndKeepPosAndSelection
SetExpandedAndKeepPosAndSelection(TreeViewItem?, bool)
Expands or collapses the specified TreeViewItem while preserving the current scroll position and selection.
public virtual void SetExpandedAndKeepPosAndSelection(TreeViewItem? item, bool expanded)
Parameters
itemTreeViewItemThe TreeViewItem to expand or collapse. If
itemisnullor does not have child items, the method does nothing.expandedbool
Remarks
This method ensures that the scroll position and the selected item in the associated ListBox remain unchanged after the operation.