title: Reloading/replacing a new table into WPF DataGrid at runtime
body: <p>I've been trying to essentially replace the whole table that is auto generated by the DataGrid control with a new DataTable.</p>
  <p>I looked at <a href="https://stackoverflow.com/questions/7215409/how-to-refresh-reload-datagrid-in-wpf">this question</a> before, but I've been trying to avoid referencing UI elements in my viewmodel class (or adding code to the Mainwindow.xaml.cs as a last resort).</p>
  <p>First I bound the ItemsSource for a DataGrid to a DataView property I have in my Viewmodel:</p>
  <pre><code>&lt;DataGrid Grid.Row=&quot;1&quot; Grid.Column =&quot;1&quot; ItemsSource=&quot;{Binding DisplayView}&quot;/&gt;
  
  private DataView displayView;
  
  public DataView DisplayView
  {
      get { return displayView; }
      set { displayView = value; }
  }
  </code></pre>
  <p>I also have a method that formats an SQL table into an appropriate DataTable, which I then assign to the DataView bound to the grid.</p>
  <pre><code>DisplayView = dtCloned.DefaultView;
  </code></pre>
  <p>When I call this method in the constructor, the table fills up on execution.</p>
  <p>Calling it during runtime creates a new table in the same format, but assigning it to the DataView property doesn't reload the DataGrid to show the new table; where am I going wrong?</p>