title: How to Dynamically Bind XML to a WPF DataGrid in C#
body: <p>I looked around for this, but all the examples I could find used XAML, which made the solution too static.  Here is what I want to do:</p>
  
  <p>I would like to populate a DataGrid's columns, rows and attributes from an XML file to be specified at run time.  Nothing about the DataGrid's attributes can be fixed; the XML drives it down to the last detail (hence why the XAML examples I saw aren't sufficient).</p>
  
  <p>The details of the XML file are open, so any layout will do, but as an example:</p>
  
  <pre><code>&lt;data&gt;
      &lt;row Column="Col 1" Value="100" /&gt;
      &lt;row Column="Col 2" Value ="200" /&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>Would yield a grid of 2 columns named Column &amp; Value respectively with the values ("Col 1", 100) &amp; ("Col 2", 200) for the row 1 &amp; 2, respectively.</p>
  
  <p>Again, I have no problem with radically different XML, so I'll take what works.</p>
  
  <p>Something like this seems very useful as it would allow the creation of generic data viewing components in a variety of domains.  XML would offer a convenient generic format for transmitting structured data and the DataGrid would offer a rich viewing experience.</p>