protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
{
switch (e.Action)
{
case NotifyCollectionChangedAction.Remove:
case NotifyCollectionChangedAction.Reset:
case NotifyCollectionChangedAction.Replace:
if (SelectedItem != null)
{
// Synchronize SelectedItem after Remove, Replace or Reset operations.
ForceCoerceSelectedItem();
}
if (HighlightedItem != null)
{
// Synchronize HighlightedItem after Remove, Replace or Reset operations.
ForceCoerceHighlightedItem();
}
break;
case NotifyCollectionChangedAction.Add:
case NotifyCollectionChangedAction.Move:
break;
}
}