title: WPF ObservableCollection not updating DataGrid when creating a new ObservableCollection
body: <p>I have a <code>DataGrid</code> that is bound to an <code>ObservableCollection</code> in the <code>ViewModel</code>.  This is a search results <code>DataGrid</code>.  The problem is that after I update the search results <code>ObservableCollection</code> the actual <code>DataGrid</code> is not updated.</p>
  
  <p>Before I get down voted to nothing, <strong>please note this is NOT</strong> about data in the columns (that bind works perfectly) <strong>it is</strong> about clearing and then placing completely new data into <code>ObservableCollection</code> that is not updating the <code>DataGrid</code>.  <a href="https://stackoverflow.com/questions/8555729/observablecollection-not-updating-view">So linking to something like this will not help as my properties are working correctly</a></p>
  
  <p>Background:</p>
  
  <p>The <code>ObservableCollection</code> is declared in the <code>ViewModel</code> like this;</p>
  
  <pre><code>public ObservableCollection&lt;MyData&gt; SearchCollection { get; set; }
  </code></pre>
  
  <p>The search <code>DataGrid</code> that is bound to my search <code>ObservableCollection</code> like this;</p>
  
  <pre><code>&lt;DataGrid  ItemsSource="{Binding SearchCollection}" /&gt;
  </code></pre>
  
  <p>In the <code>ViewModel</code> I have a search method like this;</p>
  
  <pre><code>var results =
        from x in MainCollection
        where x.ID.Contains(SearchValue)
        select x;
   SearchCollection = new ObservableCollection&lt;MyData&gt;(results);
  </code></pre>
  
  <p>The method fires correctly and produces the desired results.  Yet the <code>DataGrid</code> is not updated with the new results.  I know the <code>ViewModel</code> has the correct data because if I put a button on the Page and in the click event put this code;</p>
  
  <pre><code>private void selectPromoButton_Click(object sender, System.Windows.RoutedEventArgs e)
  {
      var vm = (MyViewModel)DataContext;
      MyDataGrid.ItemsSource = vm.SearchCollection;
  }
  </code></pre>
  
  <p>The <code>DataGrid</code> now correctly shows the results.</p>
  
  <p>I know I could put some event in the code behind of the Page but wouldn't that defeat MVVM?  What is the correct MVVM way to handle this?</p>