void redditViewModelCollection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, ObservableCollection<PivotItem> adaptedTarget)
{
switch (e.Action)
{
case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
if (e.NewStartingIndex == adaptedTarget.Count)
{
if (adaptedTarget.Count == 0)
{
var firstResult = MapViewModel(e.NewItems[0] as ViewModelBase);
firstResult.Content = new RedditView { DataContext = e.NewItems[0] };
adaptedTarget.Add(firstResult);
}
else
adaptedTarget.Add(MapViewModel(e.NewItems[0] as ViewModelBase));
}
else
{
adaptedTarget.Insert(e.NewStartingIndex, MapViewModel(e.NewItems[0] as ViewModelBase));
}
break;
case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
break;
case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
adaptedTarget.RemoveAt(e.OldStartingIndex);
break;
case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
adaptedTarget[e.OldStartingIndex] = MapViewModel(e.NewItems[0] as ViewModelBase);
break;
case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
adaptedTarget.Clear();
break;
default:
break;
}
}