private void OnExpandedItemCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { ToggleItemRowsExpansion(e.NewItems, true); } if (e.Action == NotifyCollectionChangedAction.Remove) { ToggleItemRowsExpansion(e.OldItems, false); } if (e.Action == NotifyCollectionChangedAction.Replace) { ToggleItemRowsExpansion(e.OldItems, false); ToggleItemRowsExpansion(e.NewItems, true); } if (e.Action == NotifyCollectionChangedAction.Reset) { for (int i = 0; i < TargetControl.VisibleRowCount; i++) { int rowHandle = TargetControl.GetRowHandleByVisibleIndex(i); if (TargetControl.IsGroupRowHandle(rowHandle)) { continue; } if (TargetControl.IsMasterRowExpanded(rowHandle)) { TargetControl.CollapseMasterRow(rowHandle); } } } }