private void OnCustomGeneratorItemsChanged(object sender, CustomGeneratorChangedEventArgs e) { switch (e.Action) { //In case of a Reset, nothing to do since the Panel base class has cleared the internal children already! case NotifyCollectionChangedAction.Reset: if (this.InternalChildren.Count > 0) { this.RemoveInternalChildRange(0, this.InternalChildren.Count); } else { this.InvalidateMeasure(); } break; //If there was a removal (collapsing) //or if there was a Move (edition of a Sorted field) case NotifyCollectionChangedAction.Move: case NotifyCollectionChangedAction.Remove: //remove the concerned range int index = e.OldPosition.Index; if (e.OldPosition.Offset != 0) { index++; } this.RemoveInternalChildRange(index, e.ItemUICount); break; //if some items were added (expansion) case NotifyCollectionChangedAction.Add: //invalidate layout so that the items will be inserted in place! this.InvalidateMeasure(); break; case NotifyCollectionChangedAction.Replace: Debug.Fail("NotifyCollectionChangedAction.Replace"); break; default: break; } }
private void HandleGeneratorItemsChanged(object sender, CustomGeneratorChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: { this.OnItemsAdded(e.Position, e.Index, e.ItemCount); break; } case NotifyCollectionChangedAction.Move: { this.OnItemsMoved(e.Position, e.Index, e.OldPosition, e.OldIndex, e.ItemCount, e.ItemUICount, e.RemovedContainers); break; } case NotifyCollectionChangedAction.Remove: { this.OnItemsRemoved(e.Position, e.Index, e.OldPosition, e.OldIndex, e.ItemCount, e.ItemUICount, e.RemovedContainers); break; } case NotifyCollectionChangedAction.Replace: { this.OnItemsReplaced(e.Position, e.Index, e.OldPosition, e.OldIndex, e.ItemCount, e.ItemUICount, e.RemovedContainers); break; } case NotifyCollectionChangedAction.Reset: { this.OnItemsReset(); break; } default: { throw new System.ComponentModel.InvalidEnumArgumentException("An unknown action was specified."); } } }