Skip to content

Commit

Permalink
Fix bug that causes crash in ReactiveCollection[n] = Foo
Browse files Browse the repository at this point in the history
  • Loading branch information
anaisbetts committed Oct 31, 2010
1 parent 6b334ef commit 72fadbe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ReactiveXaml/ReactiveCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,13 @@ public ReactiveCollection<TNew> CreateDerivedCollection<TNew>(Func<T, TNew> Sele
case NotifyCollectionChangedAction.Add:
case NotifyCollectionChangedAction.Remove:
case NotifyCollectionChangedAction.Replace:
// NB: SL4 fills in OldStartingIndex with -1 on Replace :-/
int old_index = (x.EventArgs.Action == NotifyCollectionChangedAction.Replace ?
x.EventArgs.NewStartingIndex : x.EventArgs.OldStartingIndex);
if (x.EventArgs.OldItems != null) {
foreach(object _ in x.EventArgs.OldItems) {
ret.RemoveAt(x.EventArgs.OldStartingIndex);
ret.RemoveAt(old_index);
}
}
if (x.EventArgs.NewItems != null) {
Expand Down

0 comments on commit 72fadbe

Please sign in to comment.