title: About using DataGrid in WPF w/ DataTable under MVVM
body: <p>(C#) Recently I am trying to display SQL results from Access MDB to DataGrid upon pressing a button in .xaml. So far I succeed in using ICommand to trigger the SQL and return the results inside a DataTable. I also used PropertyChangedEventHandler to notify the GUI. However, the DataGrid in .xaml does not refresh. (the datagrid appearance remains unchanged)</p>
  
  <p>In the ViewModel, I used below to notify the GUI:</p>
  
  <pre><code>public DataTable TblData
  {  
      get { return _dataTable; }
      set
      {
          _dataTable = value;
          RaisePropertyChanged("TblData");
      }
  }
  </code></pre>
  
  <p>In the .xaml.cs, I set the DataContext to my ViewModel:</p>
  
  <pre><code>public MainWindow()
  {
      InitializeComponent();
      this.DataContext = _dataViewModel;
  }
  </code></pre>
  
  <p>In the .xaml, I already bind the DataGrid to the DataTable:</p>
  
  <pre><code>&lt;DataGrid Grid.Column="1" Grid.Row="1" 
      ItemsSource="Binding Path=TblData, Mode=OneWay NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged" 
      AutoGenerateColumns="True" /&gt;
  </code></pre>
  
  <p>Any idea on what I should do to fix? (using MVVM)</p>
  
  <p>Or is there any other better way to do it?</p>
  
  <p>Thanks.</p>