title: Custom IEnumerable as ItemsSource for ListBox
body: <p>I have a class that defines a custom GetEnumerator() function(by implementing IEnumerable&lt;>). I use it to iterate in a contiguous manner over several <code>ObservableCollection&lt;LogEvent&gt;</code> that are in every TestStep. I have a private <code>ObservableCollection&lt;TestStep&gt;</code> that contains all the needed data.</p>
  
  <p>I would like to use an instance of this class as the ItemsSource of a ListBox. However, the ListBox never gets updated when the underlying data(<code>ObservableCollection&lt;LogEvent&gt;</code>) is updated. Here's a sample of that class:</p>
  
  <pre><code>public class FlatLogViewModel : IEnumerable&lt;LogEvent&gt;
  {
      public FlatLogViewModel(ObservableCollection&lt;TestStep&gt; subSteps)
      {
          m_subSteps = subSteps;            
      }
  
      public IEnumerator&lt;LogEvent&gt; GetEnumerator()
      {
          foreach (TestStep step in SubSteps)
          {
              // step.LogEvents is an ObservableCollection&lt;LogEvent&gt;
              foreach (LogEvent logEvent in step.LogEvents)
                  yield return logEvent;
      }
  
      IEnumerator IEnumerable.GetEnumerator()
      {
          return this.GetEnumerator();
      }
  
      private ObservableCollection&lt;TestStep&gt; m_subSteps;
  }
  </code></pre>
  
  <p>I'm not sure if I should/can implement INotifyCollectionChanged here. How can I know if ObservableCollection has been modified?</p>
  
  <p>My question is: how can I get the ListBox to display the changes happening in LogEvents(which is of type <code>ObservableCollection&lt;LogEvent&gt;</code>)?</p>