title: DataGrid with Empty DataTable to allow user input C# WPF
body: <p>I have an application that has multiple tabs each containing a Datagrid that contains data from my database.  I have a save button that writes all the datagrids into a .csv file.  I want to create an additional tab that contains an empty datagrid so the user can type information so it can be output the same way.</p>
  
  <p>Is there a way to bind a datagrid to an empty data table?  Or is there a better solution that will allow the user to dynamically enter variable amounts of information (somtimes one row, somtimes 10)</p>
  
  <p>C#</p>
  
  <pre><code>DataTable dt_Call_Drivers = new DataTable();
  Call_Drivers_DataGrid.ItemsSource = dt_Call_Drivers.DefaultView;
  </code></pre>
  
  <p>XAML</p>
  
  <pre><code>                        &lt;DataGrid x:Name="Call_Drivers_DataGrid" ItemsSource="{Binding}" GridLinesVisibility="Horizontal" CanUserAddRows="true" AutoGenerateColumns="False" Margin="0,0,0,0"&gt;
                              &lt;DataGrid.ColumnHeaderStyle&gt;
                                  &lt;Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MetroDataGridColumnHeader}"&gt;
                                      &lt;Setter Property="HorizontalContentAlignment" Value="Center" /&gt;
                                  &lt;/Style&gt;
                              &lt;/DataGrid.ColumnHeaderStyle&gt;
                              &lt;DataGrid.Columns&gt;
                                  &lt;DataGridTextColumn Header="Case"  Width ="90" Binding="{Binding Case}"&gt;
                                      &lt;DataGridTextColumn.ElementStyle&gt;
                                          &lt;Style&gt;
                                              &lt;Setter Property="TextBlock.TextAlignment" Value="Center" /&gt;
                                          &lt;/Style&gt;
                                      &lt;/DataGridTextColumn.ElementStyle&gt;
                                  &lt;/DataGridTextColumn&gt;
                              &lt;/DataGrid.Columns&gt;
                          &lt;/DataGrid&gt;
  </code></pre>