title: Populate Observable Collection from LINQ query results
body: <p>I'm just starting with WPF MVVM &amp; I'm trying to populate a datagrid view by binding to an <code>ObservableCollection</code> in my view model.</p>
  
  <p>I have used a simple LINQ query to select all from my table and populate my observable collection but my UI won't display the grid results, presumably because the XAML has to bind to a public property?</p>
  
  <pre><code>private void getTableResults()
  {
      var query = from c in LDB.myTable
                  select c;
      var results = query;
  
      ObservableCollection&lt;myTable&gt; MyCollection = new ObservableCollection&lt;myTable&gt;(results);
      OnPropertyChanged("MyCollection");
  }
  </code></pre>
  
  <p>Here's my XAML binding:</p>
  
  <pre><code>&lt;DataGrid ItemsSource="{Binding MyCollection}"
  </code></pre>
  
  <p>My <code>DataContext</code> is set and I've checked it binds against another hard-coded property. Where am I going wrong? I've put a breakpoint over the collection so know that it is being populated by the results. How can I expose a public <code>ObservableCollection</code> property which is populated from my LINQ results?</p>
  
  <p>Thanks</p>
  
  <p>Just to add, my data model is MyTable which is an Entity Framework 4.0 edmx.</p>