title: When binding an ObservableCollection<T> to a ListView, how does the ListView go about retrieving the data to display?
body: <p>I was browsing around Microsoft's site, and got caught up reading <a href="http://msdn.microsoft.com/en-us/library/ms668604.aspx" rel="nofollow">ObservableCollection&lt;T&gt;</a>.</p>
  
  <p>I came up with a quick scenario in my head, and determined I could actually use something like this.</p>
  
  <p>I made a sample class that inherets from ObservableCollection&lt;T&gt;, as seen here:</p>
  
  <pre><code>public class Ledger : ObservableCollection&lt;LedgerEntry&gt;, IEnumerable
  {
      private ObservableCollection&lt;LedgerEntry&gt; _items;
      private decimal _currentBalance;
  
      public Ledger(IEnumerable&lt;LedgerEntry&gt; items)
          : base(items)
      {
          _items = new ObservableCollection&lt;LedgerEntry&gt;(items);
          _currentBalance = 0m;
      }
  
      public new IEnumerator GetEnumerator()
      {
          var enumerator = _items.GetEnumerator();
  
          while (enumerator.MoveNext())
          {
              var currentItem = enumerator.Current;
  
              _currentBalance += currentItem.Amount;
              currentItem.SetBalance(_currentBalance);
  
              yield return currentItem;
          }
      }
  }
  </code></pre>
  
  <p>Think about a bank account -- I'd like for each LedgerEntry contained within the collection to "know" it's balance. </p>
  
  <p>Any who --</p>
  
  <p>What I'm wondering is this -- given the above example, I see that GetEnumerator() is called once when I bind it to a ListView, and now I'm curious -- how is ListView actually retrieving / viewing the data contained within the collection?</p>
  
  <p>My thought was that it would iterate the enumerable, but apparently I'm incorrect.</p>
  
  <p>Any info on how this works?</p>
  
  <p>Thanks!</p>