title: Observable collection not updating listbox
body: <p>I am using an observable collection as an item source for my WPF listbox. In code this means:</p>
  
  <pre><code>private readonly ObservableCollection&lt;AssetBrowserFilePreviewElement&gt; mLastElements; // = new ...
  
  private void OnInitialized(object sender, EventArgs args)
  {
      mBrowser.SelectedFilesListView.ItemsSource = mLastElements;
  }
  
  // in another method:
  mLastElements.Clear();
  foreach(var elem in elements)
      mLastElements.Add(elem);
  </code></pre>
  
  <p>(OnInitialized gets called and elements is not empty)</p>
  
  <p>As written in the title my problem is that adding and removing items from the collection has absolutely no effect on the listbox, it always remains empty. If I bind the <code>IEnumerable&lt;AssetBrowserFilePreviewElement&gt; elements</code> as ItemsSource instead of this Clear and Add-loop i get the expected results. In this case it would work this way but in other methods i want to selectively remove or add items and therefore I need the observable collection to work.</p>
  
  <p>What else do I have to do to propagate modifications to the collection to the listbox?</p>
  
  <p><strong>EDIT:</strong>
  As suggested in the response I've created a property and a binding in XAML but still no response whatsoever.</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;ListBox Padding="10,10,10,10" x:Name="SelectedFilesListView" Grid.Row="1" ItemsSource="{Binding Path=CurrentFiles}"&gt;
  </code></pre>
  
  <p>C#:</p>
  
  <pre><code>private readonly ObservableCollection&lt;AssetBrowserFilePreviewElement&gt; mCurFiles = new ObservableCollection&lt;AssetBrowserFilePreviewElement&gt;();
  public ObservableCollection&lt;AssetBrowserFilePreviewElement&gt; CurrentFiles { get { return mCurFiles; } }
  
  
  CurrentFiles.Clear();
  foreach(var elem in elements)
      CurrentFiles.Add(elem);
  </code></pre>
  
  <p>CurrentFiles getter gets called when the control loads. The method that modifies the collection gets called as well, elements.Count == 18, no visual change.</p>
  
  <p><strong>EDIT 2:</strong>
  I have added a test element to CurrentFiles in the constructor of AssetBrowserViewModel (where the Property is defined and which is set as DataContext). This item shows up, but modifying the elements of the collection keeps showing that test element.</p>