private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
this.UpdateContainerForItem(e.NewStartingIndex);
return;
case NotifyCollectionChangedAction.Remove:
this.ClearContainerForItemOverride(elements[e.OldStartingIndex], e.OldItems[0] as UIElement);
return;
case NotifyCollectionChangedAction.Replace:
this.ClearContainerForItemOverride(elements[e.NewStartingIndex], e.OldItems[0] as UIElement);
elements.RemoveAt(e.NewStartingIndex);
this.UpdateContainerForItem(e.NewStartingIndex);
return;
case NotifyCollectionChangedAction.Reset:
this.ClearVisualChildren(this.GetItems());
break;
default:
return;
}
}