title: WPF DataGrid binding with ObservableCollection
body: <p>I'm trying to bind a ObservableCollection with rows of data to my datagrid.
  I'm aiming on making the datagrid update itself (if data is added), it didn't worked when using a DataTable.
  I tested this approach and it works just fine, my datagrid ist bound to ResultTable property and the property names are the column names.</p>
  
  <pre><code>public class MainWindowViewModel
  {
      public MainWindowViewModel()
      {
          ResultTable = new ObservableCollection&lt;Row&gt;();
          ResultTable.Add(new Row() { Name = "Peter", Age = "21", Sex = "Male" });
          ResultTable.Add(new Row() { Name = "Sara", Age = "25", Sex = "Female" });
          ResultTable.Add(new Row() { Name = "Mike", Age = "28", Sex = "Male" });
      }
  
      public ObservableCollection&lt;Row&gt; ResultTable { get; set; }
  }
  
  public class Row
  {
      public string Name { get; set; }
      public string Age { get; set; }
      public string Sex { get; set; }
  }
  </code></pre>
  
  <p>Now my question is, how can I do this dynamically?
  This was my second approach and looks like nothing in the DataGrid...</p>
  
  <pre><code>public class MainWindowViewModel
  {
      public MainWindowViewModel()
      {
          ResultTable = new ObservableCollection&lt;Row&gt;();
          var row = new Row();
          row.Columns.Add(new Item() { Name = "Name", Value = "Peter" });
          row.Columns.Add(new Item() { Name = "Age", Value = "21" });
          row.Columns.Add(new Item() { Name = "Sex", Value = "Male" });
          ResultTable.Add(row);
      }
  
      public ObservableCollection&lt;Row&gt; ResultTable { get; set; }
  }
  
  public class Row
  {
      public List&lt;Item&gt; Columns = new List&lt;Item&gt;();
  }
  
  public class Item
  {
      public string Name { get; set; }
      public string Value { get; set; }
  }
  </code></pre>
  
  <p>But now the question is, how can I say the DataGrid that each Name property in columns List is the column header.
  And each Value is the value of the row?</p>
  
  <p>This is my xaml (nothing fancy):</p>
  
  <pre><code>&lt;Window x:Class="WpfApplication1.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:local="clr-namespace:WpfApplication1"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Window.DataContext&gt;
          &lt;local:MainWindowViewModel x:Name="MainWindowViewModel" /&gt;
      &lt;/Window.DataContext&gt;
      &lt;Grid&gt;
          &lt;DataGrid ItemsSource="{Binding ResultTable}"
                    AutoGenerateColumns="True" /&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>