Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Collections.ObjectModel;
|
---|
6 | using System.Collections.Specialized;
|
---|
7 |
|
---|
8 | namespace Microsoft.Research.DynamicDataDisplay.Common.Auxiliary
|
---|
9 | {
|
---|
10 | internal static class ObservableCollectionHelper
|
---|
11 | {
|
---|
12 | public static void ApplyChanges<T>(this ObservableCollection<T> collection, NotifyCollectionChangedEventArgs args)
|
---|
13 | {
|
---|
14 | if (args.NewItems != null)
|
---|
15 | {
|
---|
16 | int startingIndex = args.NewStartingIndex;
|
---|
17 | var newItems = args.NewItems;
|
---|
18 |
|
---|
19 | for (int i = 0; i < newItems.Count; i++)
|
---|
20 | {
|
---|
21 | T addedItem = (T)newItems[i];
|
---|
22 | collection.Insert(startingIndex + i, addedItem);
|
---|
23 | }
|
---|
24 | }
|
---|
25 | if (args.OldItems != null)
|
---|
26 | {
|
---|
27 | for (int i = 0; i < args.OldItems.Count; i++)
|
---|
28 | {
|
---|
29 | T removedItem = (T)args.OldItems[i];
|
---|
30 | collection.Remove(removedItem);
|
---|
31 | }
|
---|
32 | }
|
---|
33 | }
|
---|
34 | }
|
---|
35 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.