title: to get current generic item item inside of CollectionChanged
body: <p>I have a custom collection that inherits IEnumerable.</p>
  
  <pre><code>public class MyCollection&lt;T&gt; : IEnumerable&lt;T&gt;   
  {
      private ObservableCollection&lt;T&gt; currentList = new ObservableCollection&lt;T&gt;();
  
      public ObservableCollection&lt;T&gt; Items
      {
          get { return currentList; }  
          set { currentList = value; }
      }
  
      private List&lt;T&gt; deletedList = new List&lt;T&gt;();
      private List&lt;T&gt; addedList = new List&lt;T&gt;();
  
      public MyCollection(IEnumerable&lt;T&gt; currentList)
      {
          this.currentList = new ObservableCollection&lt;T&gt;(currentList);
          Items.CollectionChanged+=Items_CollectionChanged;
      }
  }
  </code></pre>
  
  <p>I wish to track which items were added or deleted . Also , My Items is databound to a UI datagrid in WPF. The binding works fine if i bind to the Items instead of MyCollection . However , I want to track the added , removed items as below.
  Am assuming the following event is caught when I add or remove any item from the UI.</p>
  
  <p>As each row gets added to the DataGrid , I wish this even to be called to save the last added entry.</p>
  
  <p>Now how do I get the current added or removed item in this ?</p>
  
  <pre><code>private void Items_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
  {  
      if (e.Action == NotifyCollectionChangedAction.Remove)
      {
          //this doesn't work  ( I List is not assignable to IEnumerable T
          deletedList.AddRange(e.OldItems);
      }
  
      if (e.Action == NotifyCollectionChangedAction.Add)
      {
          //this doesnt work 
          addedList.AddRange(e.OldItems);
      }
  }
  </code></pre>
  
  <p>I only get the added or deleted items .</p>
  
  <pre><code>public ObservableCollection&lt;T&gt; GetAddedChanges()
  {
      var added = new ObservableCollection&lt;T&gt;();
      addedList.ToList().ForEach(added.Add);
  
      return added;
  }
  
  public ObservableCollection&lt;T&gt; GetDeletedChanges()
  {
      var deleted = new ObservableCollection&lt;T&gt;();
      deletedList.ToList().ForEach(deleted.Add);
      return deleted;
  }
  </code></pre>
  
  <p>UPDATE :
  The initial answer here worked i.e the Cast() option and I was able to get only the added members from my list and save them.</p>
  
  <p>There is another issue . I am getting my server to return MyCollection . The sad thing is that my server when it de serializes to collection objects , it gets caught by the Added event of the Items_CollectionChanged  , hence my added List faultily returns 2 items in added list always .</p>
  
  <p>To solve this :</p>
  
  <p>1) Subscribe to the event after server returns instead of MyCollection constructor. i.e Subscribe in another StartTracking( ).</p>
  
  <p>2) Clear the added, deletd lists after getting the response from server .</p>
  
  <p>Which of these would be better ? And are there any alternate solutions ?</p>
  
  <p>This is the flow basically :</p>
  
  <p>UI -- > OBservableCollection --> MyCollection ( where I track added /del elements )  --> Save to Server    ..   To fetch from server , I have my server side code return MyCollectionwith entries in it.</p>