Method ToggleExpandedAndCollapseSiblings
ToggleExpandedAndCollapseSiblings(TreeViewItem?, bool)
Toggles the expanded state of the specified tree item and optionally
collapses its sibling items.
If collapseSiblings is true and the item has
a parent, all sibling items are collapsed before toggling.
public virtual bool ToggleExpandedAndCollapseSiblings(TreeViewItem? item, bool collapseSiblings)
Parameters
itemTreeViewItemThe target tree item to expand or collapse.
collapseSiblingsboolIndicates whether sibling items under the same parent should be collapsed before expanding the target item.
Returns
- bool
trueif the toggle action was successfully applied;falseif the item isnullor has no child items.
Remarks
This method is typically used during user interactions to enforce exclusive
expansion behavior.
It does not apply collapse logic if the item has no parent or
if collapseSiblings is false.