title: Simple WPF binding question. Binding DataGrid to one structure and array(list) of structures
body: <p>I want to display the contents of a binary file in a few simple DataGrids (xmlns:kit="http://schemas.microsoft.com/wpf/2008/toolkit").  I know the layout of the file; it's quite simple. </p>
  
  <p>First I have several simple structs of the form:</p>
  
  <pre><code>[StructLayout(LayoutKind.Sequential, Pack = 1)]
  public class PartitionBasicStationData
  {
    public uint longitude;
    public uint latitude;
    public uint StationCode;
  
  }
  </code></pre>
  
  <p>I have just one intance of these in the file.  Although it's probably overkill, I'd like to throw it in a Datagrid.  I was hoping I'd automatically get some simple column headers like, "longitude", "latitude", etc. My XAML looks like:</p>
  
  <pre><code>&lt;kit:DataGrid Name="m_gridPartion1" MinWidth="120" MinHeight="120"&gt;&lt;/kit:DataGrid&gt;
  </code></pre>
  
  <p>and in code, after I successfully read the binary file and create a structure, I do this:</p>
  
  <pre><code>m_gridPartion1.ItemsSource = new Partition1[1] { partition1 };
  //m_gridPartion1.DataContext = new Partition1[1]{partition1}; // also tried this
  // m_gridPartion1.ItemsSource = partion1; // and I tried this
  </code></pre>
  
  <p>Should this work?  </p>
  
  <p>For my second grid I will also have simple structures, but many of them.  The structure looks like</p>
  
  <pre><code>[StructLayout(LayoutKind.Sequential, Pack = 1)]
  public class Datum
  {
    public uint temperature;
    public uint windVelocity;
  
  }
  </code></pre>
  
  <p>I was hoping I could just do something like this:</p>
  
  <pre><code> m_gridData.ItemsSource = myList;  // myList is List&lt;Datum&gt;
  </code></pre>
  
  <p>Any tutorials or pointers would be much appreciated.  Most of the material I've come across is about binding from XAML (which I'm not opposed to if it's easy) or is overkill (setting column names, etc.).</p>
  
  <p>Thanks,</p>
  
  <p>Dave</p>