title: Updating DataGrid on button click in another window
body: <p>I have two windows: (1) <code>Home</code> and (2) <code>Add</code>
  What I want to do is to update the <code>DataGrid</code> on <code>Home</code> whenever I hit the <code>Submit</code> button on the <code>Add</code> page.</p>
  
  <p>The data loaded in the <code>DataGrid</code> is a <code>CSV File</code>. I'm hoping to accomplish this without the use of <code>MVVM</code> if that is possible.</p>
  
  <p>So far, the code that I have works but only on the first run. For example, I fill up the fields in <code>Add</code> then hit the <code>Submit</code> button for the first time. The <code>DataGrid</code> would update but when I try it for a second time (without closing the application), it would no longer do what I want it to do. How can I resolve this?</p>
  
  <p><code>Submit</code> button click event in <code>Add</code></p>
  
  <pre><code> public void btn_Submit_Click(object sender, RoutedEventArgs e)
      {           
          save();
          string edata = @"Employees.txt";
          Home h = new Home();
          h.grid.ItemsSource = edata.ToList();
          btn_clear_Click(sender, e);
          error_mssg.Text = "** SUCCESS! **";            
      }
  </code></pre>
  
  <p><code>Home</code> page xaml</p>
  
  <pre><code>&lt;StackPanel Margin="0 10 0 0"&gt;
      &lt;DataGrid x:Name="grid" Height="400" ItemsSource="{Binding}"/&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p><code>Home</code> page cs</p>
  
  <pre><code>public void Populate()
  {       
      DataTable table = LoadDataGrid.display(@"EmployeeData.txt");
      grid.DataContext = table;
  }
  </code></pre>
  
  <p><code>LoadDataGrid</code> cs</p>
  
  <pre><code>public static DataTable display(string path)
  {
      DataTable dt = new DataTable();
      using (StreamReader sr = new StreamReader(path))
      {
          string[] headers = sr.ReadLine().Split(',');
          foreach (string header in headers)
          {
              dt.Columns.Add(header);
          }
          while (!sr.EndOfStream)
          {
              string[] rows = sr.ReadLine().Split(',');
              DataRow dr = dt.NewRow();
              for (int i = 0; i &lt; headers.Length; i++)
              {
                  dr[i] = rows[i];
              }
              dt.Rows.Add(dr);
          }
  
      }
      return dt;
  }
  </code></pre>
  
  <p>I also added the code I used to populate the DataGrid with the contents of the csv file in case it is needed.</p>
  
  <p>I also tried doing</p>
  
  <pre><code>h.grid.Items.Refresh();
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>h.grid.ItemsSource = edata.ToList();
  </code></pre>