title: Bind DataTables to DataGrids in WrapPanel
body: <p>While making WPF app, I have a list(not a necessary list but can be any container or array) of DataTables, and I want to display all these tables in a wrappanel. The number of DataTables can change and each DataTable can have any number of rows, but the columns are fixed and are same for all DataTables.</p>
  <p>Previously what I have been doing is creating a wrappanel in XAML and adding Datagrid into that wrappanel from code behind(C#), for example:</p>
  <p><em>XAML</em></p>
  <pre class="lang-xml prettyprint-override"><code>&lt;WrapPanel Name=&quot;WPnl&quot;&gt;
  &lt;/WrapPanel&gt;
  </code></pre>
  <p><em>c#</em></p>
  <pre class="lang-cs prettyprint-override"><code>void addTable(DataTable Table)
  {
      dataGrid = new DataGrid();
      dataGrid.ItemsSource = Table.DefaultView;
      WPnl.Children.Add(dataGrid);
  }
  </code></pre>
  <p>What I want to do is that these Tables have a fixed layout so somehow creating Datagrid in XAML as static layout and instancing new Datagrids of this layout and adding them to wrappanel and binding that Datagrid to a Datatable which can change in future.
  I don't know if it is even possible or not. If not then can there be anything used to optimize above in terms of time? Keeping in mind that the number of tables and number of rows in each table can change dynamically.</p>
  <p>Like in <a href="https://stackoverflow.com/questions/20770438/how-to-bind-datatable-to-datagrid">this</a> post I want to bind a single DataTable to single DataGrid but number of these DataTables can change.</p>